aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/LICM.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
committerDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
commitdff6710717b159f089c76a07eda074eb6347eb92 (patch)
tree7bbd754ebe64f5d4bbc6000e0e66bdd99f9c847f /lib/Transforms/Scalar/LICM.cpp
parente3110d0825e6316fd2dd21d6a4e593295cd413f1 (diff)
downloadexternal_llvm-dff6710717b159f089c76a07eda074eb6347eb92.zip
external_llvm-dff6710717b159f089c76a07eda074eb6347eb92.tar.gz
external_llvm-dff6710717b159f089c76a07eda074eb6347eb92.tar.bz2
Integrate the readonly/readnone logic more deeply
into alias analysis. This meant updating the API which now has versions of the getModRefBehavior, doesNotAccessMemory and onlyReadsMemory methods which take a callsite parameter. These should be used unless the callsite is not known, since in general they can do a better job than the versions that take a function. Also, users should no longer call the version of getModRefBehavior that takes both a function and a callsite. To reduce the chance of misuse it is now protected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LICM.cpp')
-rw-r--r--lib/Transforms/Scalar/LICM.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index c86b463..0c8cb4d 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -375,24 +375,22 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
return !pointerInvalidatedByLoop(LI->getOperand(0), Size);
} else if (CallInst *CI = dyn_cast<CallInst>(&I)) {
// Handle obvious cases efficiently.
- if (Function *Callee = CI->getCalledFunction()) {
- AliasAnalysis::ModRefBehavior Behavior =AA->getModRefBehavior(Callee, CI);
- if (Behavior == AliasAnalysis::DoesNotAccessMemory)
- return true;
- else if (Behavior == AliasAnalysis::OnlyReadsMemory) {
- // If this call only reads from memory and there are no writes to memory
- // in the loop, we can hoist or sink the call as appropriate.
- bool FoundMod = false;
- for (AliasSetTracker::iterator I = CurAST->begin(), E = CurAST->end();
- I != E; ++I) {
- AliasSet &AS = *I;
- if (!AS.isForwardingAliasSet() && AS.isMod()) {
- FoundMod = true;
- break;
- }
+ AliasAnalysis::ModRefBehavior Behavior = AA->getModRefBehavior(CI);
+ if (Behavior == AliasAnalysis::DoesNotAccessMemory)
+ return true;
+ else if (Behavior == AliasAnalysis::OnlyReadsMemory) {
+ // If this call only reads from memory and there are no writes to memory
+ // in the loop, we can hoist or sink the call as appropriate.
+ bool FoundMod = false;
+ for (AliasSetTracker::iterator I = CurAST->begin(), E = CurAST->end();
+ I != E; ++I) {
+ AliasSet &AS = *I;
+ if (!AS.isForwardingAliasSet() && AS.isMod()) {
+ FoundMod = true;
+ break;
}
- if (!FoundMod) return true;
}
+ if (!FoundMod) return true;
}
// FIXME: This should use mod/ref information to see if we can hoist or sink