diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 25 |
2 files changed, 24 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index a16e334e020..5fdf9a9c1a7 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -409,9 +409,9 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) { if (MemLoc.Ptr) { // If we can do a pointer scan, make it happen. bool isLoad = !(MR & AliasAnalysis::Mod); - if (IntrinsicInst *II = dyn_cast<MemoryUseIntrinsic>(QueryInst)) { + if (IntrinsicInst *II = dyn_cast<MemoryUseIntrinsic>(QueryInst)) isLoad |= II->getIntrinsicID() == Intrinsic::lifetime_end; - } + LocalCache = getPointerDependencyFrom(MemLoc, isLoad, ScanPos, QueryParent); } else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)) { diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index 1ea0b15e4c9..02df1031e60 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -217,9 +217,28 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { continue; } - // If not a definite must-alias dependency, ignore it. - if (!InstDep.isDef()) - continue; + if (!InstDep.isDef()) { + // If this is a may-aliased store that is clobbering the store value, we + // can keep searching past it for another must-aliased pointer that stores + // to the same location. For example, in: + // store -> P + // store -> Q + // store -> P + // we can remove the first store to P even though we don't know if P and Q + // alias. + if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { + AliasAnalysis::Location Loc = + getAnalysis<AliasAnalysis>().getLocation(SI); + while (InstDep.isClobber() && isa<StoreInst>(InstDep.getInst()) && + InstDep.getInst() != &BB.front()) + InstDep = MD.getPointerDependencyFrom(Loc, false, InstDep.getInst(), + &BB); + } + + // If not a definite must-alias dependency, ignore it. + if (!InstDep.isDef()) + continue; + } // If this is a store-store dependence, then the previous store is dead so // long as this store is at least as big as it. |