summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-23 23:49:47 +0000
committerChris Lattner <sabre@nondot.org>2005-03-23 23:49:47 +0000
commitec6518ddc2baa110ffdadc9ba8625ae968f746be (patch)
tree3edb0b3951be69a96776b525971240645e7813ce
parente04d51f4a5a91689367729ac2bd33f6f12d04842 (diff)
If we are calling an external function, chain to another AA to potentially
decide, don't just immediately give up. This implements GlobalsModRef/chaining-analysis.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20796 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp
index 6bf2698988a..47d7d518790 100644
--- a/lib/Analysis/IPA/GlobalsModRef.cpp
+++ b/lib/Analysis/IPA/GlobalsModRef.cpp
@@ -111,7 +111,7 @@ namespace {
return DoesNotAccessMemory;
else if ((FR->FunctionEffect & Mod) == 0)
return OnlyReadsMemory;
- return AliasAnalysis::getModRefBehavior(F, CS);
+ return AliasAnalysis::getModRefBehavior(F, CS, Info);
}
virtual void deleteValue(Value *V);
@@ -198,11 +198,6 @@ bool GlobalsModRef::AnalyzeUsesOfGlobal(Value *V,
// passing into the function.
for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
if (CI->getOperand(i) == V) return true;
- } else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
- // Make sure that this is just the function being called, not that it is
- // passing into the function.
- for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
- if (CI->getOperand(i) == V) return true;
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
// Make sure that this is just the function being called, not that it is
// passing into the function.
@@ -279,8 +274,25 @@ void GlobalsModRef::AnalyzeSCC(std::vector<CallGraphNode *> &SCC) {
FR.GlobalInfo[GI->first] |= GI->second;
} else {
- CallsExternal = true;
- break;
+ // Okay, if we can't say anything about it, maybe some other alias
+ // analysis can.
+ ModRefBehavior MRB =
+ AliasAnalysis::getModRefBehavior(Callee, CallSite());
+ if (MRB != DoesNotAccessMemory) {
+ if (MRB == OnlyReadsMemory) {
+ // This reads memory, but we don't know what, just say that it
+ // reads all globals.
+ for (std::map<GlobalValue*, unsigned>::iterator
+ GI = CalleeFR->GlobalInfo.begin(),
+ E = CalleeFR->GlobalInfo.end();
+ GI != E; ++GI)
+ FR.GlobalInfo[GI->first] |= Ref;
+
+ } else {
+ CallsExternal = true;
+ break;
+ }
+ }
}
} else {
CallsExternal = true;