diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp index 9abb62ac788c7..efb11b68a1e3f 100644 --- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp @@ -112,7 +112,7 @@ static Value *getBoundsCheckCond(Value *Ptr, Value *InstVal, /// /// \p GetTrapBB is a callable that returns the trap BB to use on failure. template <typename GetTrapBBT> -static void insertBoundsCheck(Value *Or, BuilderTy IRB, GetTrapBBT GetTrapBB) { +static void insertBoundsCheck(Value *Or, BuilderTy &IRB, GetTrapBBT GetTrapBB) { // check if the comparison is always false ConstantInt *C = dyn_cast_or_null<ConstantInt>(Or); if (C) { @@ -154,17 +154,22 @@ static bool addBoundsChecking(Function &F, TargetLibraryInfo &TLI, Value *Or = nullptr; BuilderTy IRB(I.getParent(), BasicBlock::iterator(&I), TargetFolder(DL)); if (LoadInst *LI = dyn_cast<LoadInst>(&I)) { - Or = getBoundsCheckCond(LI->getPointerOperand(), LI, DL, TLI, - ObjSizeEval, IRB, SE); + if (!LI->isVolatile()) + Or = getBoundsCheckCond(LI->getPointerOperand(), LI, DL, TLI, + ObjSizeEval, IRB, SE); } else if (StoreInst *SI = dyn_cast<StoreInst>(&I)) { - Or = getBoundsCheckCond(SI->getPointerOperand(), SI->getValueOperand(), - DL, TLI, ObjSizeEval, IRB, SE); + if (!SI->isVolatile()) + Or = getBoundsCheckCond(SI->getPointerOperand(), SI->getValueOperand(), + DL, TLI, ObjSizeEval, IRB, SE); } else if (AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I)) { - Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getCompareOperand(), - DL, TLI, ObjSizeEval, IRB, SE); + if (!AI->isVolatile()) + Or = + getBoundsCheckCond(AI->getPointerOperand(), AI->getCompareOperand(), + DL, TLI, ObjSizeEval, IRB, SE); } else if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(&I)) { - Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getValOperand(), DL, - TLI, ObjSizeEval, IRB, SE); + if (!AI->isVolatile()) + Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getValOperand(), + DL, TLI, ObjSizeEval, IRB, SE); } if (Or) TrapInfo.push_back(std::make_pair(&I, Or)); |