From: Eli Friedman Date: Wed, 15 Jun 2011 01:25:56 +0000 (+0000) Subject: Stop using memdep for a check that didn't really make sense with memdep. In terms... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5d40ef2b1df29e726cfa093fe0acd0aa97161236;p=oota-llvm.git Stop using memdep for a check that didn't really make sense with memdep. In terms of specific issues, using memdep here checks irrelevant instructions and won't work properly once we start returning "unknown" more aggressively from memdep. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133035 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 3347fc3519c..bd4c2d6d8e0 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -487,7 +487,8 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { // happen to be using a load-store pair to implement it, rather than // a memcpy. if (LoadInst *LI = dyn_cast(SI->getOperand(0))) { - if (!LI->isVolatile() && LI->hasOneUse()) { + if (!LI->isVolatile() && LI->hasOneUse() && + LI->getParent() == SI->getParent()) { MemDepResult ldep = MD->getDependency(LI); CallInst *C = 0; if (ldep.isClobber() && !isa(ldep.getInst())) @@ -496,17 +497,14 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { if (C) { // Check that nothing touches the dest of the "copy" between // the call and the store. - MemDepResult sdep = MD->getDependency(SI); - if (!sdep.isNonLocal() && !sdep.isUnknown()) { - bool FoundCall = false; - for (BasicBlock::iterator I = SI, E = sdep.getInst(); I != E; --I) { - if (&*I == C) { - FoundCall = true; - break; - } - } - if (!FoundCall) + AliasAnalysis &AA = getAnalysis(); + AliasAnalysis::Location StoreLoc = AA.getLocation(SI); + for (BasicBlock::iterator I = --BasicBlock::iterator(SI), + E = C; I != E; --I) { + if (AA.getModRefInfo(&*I, StoreLoc) != AliasAnalysis::NoModRef) { C = 0; + break; + } } }