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 | 15a43965ac9a5c6f17f99ebee7347e86e7846884 (patch) | |
| tree | bf553b8e36ac91c3e3b38fa0682d9b725b3f9963 /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | |
| parent | 310c5a8e317f2f31f2df41a1ab75e74d70f8d76a (diff) | |
| download | llvm-15a43965ac9a5c6f17f99ebee7347e86e7846884.zip llvm-15a43965ac9a5c6f17f99ebee7347e86e7846884.tar.gz llvm-15a43965ac9a5c6f17f99ebee7347e86e7846884.tar.bz2 | |
Teach memdep to use pointsToConstantMemory to determine that loads
from constant memory don't alias any stores.
llvm-svn: 117636
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
| -rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 5940105..c72cd1e 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/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); |
