From cfca06d7963fa0909f90483b42a6d7d194d01e08 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 26 Jul 2020 19:36:28 +0000 Subject: Vendor import of llvm-project master 2e10b7a39b9, the last commit before the llvmorg-12-init tag, from which release/11.x was branched. --- .../Transforms/Instrumentation/BoundsChecking.cpp | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp') diff --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp index 9abb62ac788c..efb11b68a1e3 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 -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(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(&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(&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(&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(&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)); -- cgit v1.2.3