aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/IPA/GlobalsModRef.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-09-04 19:16:20 +0000
committerDuncan Sands <baldrick@free.fr>2008-09-04 19:16:20 +0000
commitf423abc289bca6c0b0cbb3c28bfb2f844bc7398f (patch)
tree6614def29c75b0b97a08f33342b69867a16a48fb /lib/Analysis/IPA/GlobalsModRef.cpp
parent10b359ccb60de3114f262d2a204f54c532758cfc (diff)
Neaten this up a bit. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/GlobalsModRef.cpp')
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp
index 3583f8db4f..70680bfed7 100644
--- a/lib/Analysis/IPA/GlobalsModRef.cpp
+++ b/lib/Analysis/IPA/GlobalsModRef.cpp
@@ -354,18 +354,17 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
for (scc_iterator<CallGraph*> I = scc_begin(&CG), E = scc_end(&CG); I != E;
++I) {
std::vector<CallGraphNode *> &SCC = *I;
+ assert(!SCC.empty() && "SCC with no functions?");
- FunctionRecord *FR = 0;
- // Find a function record from the SCC (it doesn't matter which one).
- for (unsigned i = 0, e = SCC.size(); i != e; ++i)
- if (Function *F = SCC[i]->getFunction()) {
- FR = &FunctionInfo[F];
- break;
- }
-
- if (!FR)
- // Nothing to do.
+ if (!SCC[0]->getFunction()) {
+ // Calls externally - can't say anything useful. Remove any existing
+ // function records (may have been created when scanning globals).
+ for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+ FunctionInfo.erase(SCC[i]->getFunction());
continue;
+ }
+
+ FunctionRecord &FR = FunctionInfo[SCC[0]->getFunction()];
bool KnowNothing = false;
unsigned FunctionEffect = 0;
@@ -389,7 +388,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
// mark all globals read somewhere as being read by this function.
for (std::set<GlobalValue*>::iterator GI = ReadGlobals.begin(),
E = ReadGlobals.end(); GI != E; ++GI)
- FR->GlobalInfo[*GI] |= Ref;
+ FR.GlobalInfo[*GI] |= Ref;
} else {
// Can't say anything useful.
KnowNothing = true;
@@ -398,7 +397,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
}
for (CallGraphNode::iterator CI = SCC[i]->begin(), E = SCC[i]->end();
- CI != E; ++CI)
+ CI != E && !KnowNothing; ++CI)
if (Function *Callee = CI->second->getFunction()) {
if (FunctionRecord *CalleeFR = getFunctionInfo(Callee)) {
// Propagate function effect up.
@@ -408,7 +407,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
for (std::map<GlobalValue*, unsigned>::iterator GI =
CalleeFR->GlobalInfo.begin(), E = CalleeFR->GlobalInfo.end();
GI != E; ++GI)
- FR->GlobalInfo[GI->first] |= GI->second;
+ FR.GlobalInfo[GI->first] |= GI->second;
} else {
// Can't say anything about it. However, if it is inside our SCC,
// then nothing needs to be done.
@@ -445,12 +444,12 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
++NumReadMemFunctions;
if (FunctionEffect == 0)
++NumNoMemFunctions;
- FR->FunctionEffect = FunctionEffect;
+ FR.FunctionEffect = FunctionEffect;
// Finally, now that we know the full effect on this SCC, clone the
// information to each function in the SCC.
for (unsigned i = 1, e = SCC.size(); i != e; ++i)
- FunctionInfo[SCC[i]->getFunction()] = *FR;
+ FunctionInfo[SCC[i]->getFunction()] = FR;
}
}