diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-29 01:14:04 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-29 01:14:04 +0000 |
commit | cd5c123a1d8723dbd5d493210c0a56890bffe409 (patch) | |
tree | 143c7635e0e62379d3af28da94ffe7bd14ade69c /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 1cfb04390157cdba29216e0bbc2f396124ae14a1 (diff) |
Teach memdep to use pointsToConstantMemory to determine that loads
from constant memory don't alias any stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 5940105a3a..c72cd1e83a 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -161,8 +161,9 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, } /// getPointerDependencyFrom - Return the instruction on which a memory -/// location depends. If isLoad is true, this routine ignore may-aliases with -/// read-only operations. +/// location depends. If isLoad is true, this routine ignores may-aliases with +/// read-only operations. If isLoad is false, this routine ignores may-aliases +/// with reads from read-only locations. MemDepResult MemoryDependenceAnalysis:: getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB) { @@ -225,17 +226,21 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, Value *Pointer = LI->getPointerOperand(); uint64_t PointerSize = AA->getTypeStoreSize(LI->getType()); MDNode *TBAATag = LI->getMetadata(LLVMContext::MD_tbaa); + AliasAnalysis::Location LoadLoc(Pointer, PointerSize, TBAATag); // If we found a pointer, check if it could be the same as our pointer. - AliasAnalysis::AliasResult R = - AA->alias(AliasAnalysis::Location(Pointer, PointerSize, TBAATag), - MemLoc); + AliasAnalysis::AliasResult R = AA->alias(LoadLoc, MemLoc); if (R == AliasAnalysis::NoAlias) continue; // May-alias loads don't depend on each other without a dependence. if (isLoad && R == AliasAnalysis::MayAlias) continue; + + // Stores don't alias loads from read-only memory. + if (!isLoad && AA->pointsToConstantMemory(LoadLoc)) + continue; + // Stores depend on may and must aliased loads, loads depend on must-alias // loads. return MemDepResult::getDef(Inst); |