diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-05 22:09:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-05 22:09:15 +0000 |
commit | 5fa417c7904f7394d4e6dcb86e366c86867bcb5a (patch) | |
tree | 68a0821883973c55b5f4f210abc85726e4ec50c1 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 3ecf355c7a6f6f559f3c85b46d041ffda5163a8c (diff) | |
download | external_llvm-5fa417c7904f7394d4e6dcb86e366c86867bcb5a.zip external_llvm-5fa417c7904f7394d4e6dcb86e366c86867bcb5a.tar.gz external_llvm-5fa417c7904f7394d4e6dcb86e366c86867bcb5a.tar.bz2 |
Fix memdep's code for reasoning about dependences between two calls. A Ref
response from getModRefInfo is not useful here. Instead, check for identical
calls only in the NoModRef case.
Reapply r110270, and strengthen it to compensate for the memdep changes.
When both calls are readonly, there is no dependence between them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110382 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index e97bc3b..e003d64 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -126,26 +126,15 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall, // If these two calls do not interfere, look past it. switch (AA->getModRefInfo(CS, InstCS)) { case AliasAnalysis::NoModRef: - // If the two calls don't interact (e.g. InstCS is readnone) keep - // scanning. + // If the two calls are the same, return InstCS as a Def, so that + // CS can be found redundant and eliminated. + if (isReadOnlyCall && InstCS.onlyReadsMemory() && + CS.getInstruction()->isIdenticalToWhenDefined(Inst)) + return MemDepResult::getDef(Inst); + + // Otherwise if the two calls don't interact (e.g. InstCS is readnone) + // keep scanning. continue; - case AliasAnalysis::Ref: - // If the two calls read the same memory locations and CS is a readonly - // function, then we have two cases: 1) the calls may not interfere with - // each other at all. 2) the calls may produce the same value. In case - // #1 we want to ignore the values, in case #2, we want to return Inst - // as a Def dependence. This allows us to CSE in cases like: - // X = strlen(P); - // memchr(...); - // Y = strlen(P); // Y = X - if (isReadOnlyCall) { - if (CS.getCalledFunction() != 0 && - CS.getCalledFunction() == InstCS.getCalledFunction()) - return MemDepResult::getDef(Inst); - // Ignore unrelated read/read call dependences. - continue; - } - // FALL THROUGH default: return MemDepResult::getClobber(Inst); } |