diff options
author | Owen Anderson <resistor@mac.com> | 2007-11-26 02:26:36 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2007-11-26 02:26:36 +0000 |
commit | 00a6d1448d27b5140b911caf2eca9585abdae5c8 (patch) | |
tree | d82b6247c7d85f350e2dae27128387261a2d1a32 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | fd94dd58ffef1be3597ef8cb64f3b1d476d7d5ec (diff) | |
download | external_llvm-00a6d1448d27b5140b911caf2eca9585abdae5c8.zip external_llvm-00a6d1448d27b5140b911caf2eca9585abdae5c8.tar.gz external_llvm-00a6d1448d27b5140b911caf2eca9585abdae5c8.tar.bz2 |
Allow GVN to eliminate read-only function calls when it can detect that they are redundant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 5375d52..68366f6 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -79,9 +79,6 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, if (StoreInst* S = dyn_cast<StoreInst>(QI)) { pointer = S->getPointerOperand(); pointerSize = TD.getTypeStoreSize(S->getOperand(0)->getType()); - } else if (LoadInst* L = dyn_cast<LoadInst>(QI)) { - pointer = L->getPointerOperand(); - pointerSize = TD.getTypeStoreSize(L->getType()); } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) { pointer = AI; if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize())) @@ -98,7 +95,11 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, // FreeInsts erase the entire structure pointerSize = ~0UL; } else if (CallSite::get(QI).getInstruction() != 0) { - if (AA.getModRefInfo(C, CallSite::get(QI)) != AliasAnalysis::NoModRef) { + AliasAnalysis::ModRefBehavior result = + AA.getModRefBehavior(cast<CallInst>(QI)->getCalledFunction(), + CallSite::get(QI)); + if (result != AliasAnalysis::DoesNotAccessMemory && + result != AliasAnalysis::OnlyReadsMemory) { if (!start && !block) { depGraphLocal.insert(std::make_pair(C.getInstruction(), std::make_pair(QI, true))); |