diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-31 05:46:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-31 05:46:59 +0000 |
commit | f5313424550268526a14fd910cfb59efb95e0f30 (patch) | |
tree | f248cbbd24f87afdb65f54dfa3151d22e76ce3ec /lib/Analysis | |
parent | 4c76b7e8e15bf7ed6607393535f64a9070b6df8c (diff) | |
download | external_llvm-f5313424550268526a14fd910cfb59efb95e0f30.zip external_llvm-f5313424550268526a14fd910cfb59efb95e0f30.tar.gz external_llvm-f5313424550268526a14fd910cfb59efb95e0f30.tar.bz2 |
fix a crash building SPASS by tolerating a callsite that doesn't exist
in the callgraph, see the big comment at the top of the testcase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80541 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/IPA/CallGraph.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 9711013..6490642 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -239,14 +239,19 @@ void CallGraphNode::dump() const { print(errs()); } /// specified call site. Note that this method takes linear time, so it /// should be used sparingly. void CallGraphNode::removeCallEdgeFor(CallSite CS) { - for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { - assert(I != CalledFunctions.end() && "Cannot find callsite to remove!"); - if (I->first == CS) { - I->second->DropRef(); - *I = CalledFunctions.back(); - CalledFunctions.pop_back(); - return; - } + // Scan for the call site. Note that we aren't guaranteed to find the call + // site in this node, even in reasonable situations. Passes like instcombine + // can adjust callsites (e.g. folding bitcasts into calls to make them direct) + // which can introduce new call sites. Since instcombine is not callgraph + // aware, it doesn't know to tell CallGraph about this change. + for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); + I != CalledFunctions.end(); ++I) { + if (I->first != CS) continue; + + I->second->DropRef(); + *I = CalledFunctions.back(); + CalledFunctions.pop_back(); + return; } } |