diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-09-15 05:40:35 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-09-15 05:40:35 +0000 |
| commit | e0987215f0f3b2c5c64c55c0e62d7b927e19cbd9 (patch) | |
| tree | 6c9872542ecdd7fd4d95a0bf7e87e484ede55091 /llvm/lib/Analysis | |
| parent | e5506884cc4acf9afe849830c61cf1728b21f180 (diff) | |
| download | bcm5719-llvm-e0987215f0f3b2c5c64c55c0e62d7b927e19cbd9.tar.gz bcm5719-llvm-e0987215f0f3b2c5c64c55c0e62d7b927e19cbd9.zip | |
add a new CallGraphNode::replaceCallEdge method and use it from
argpromote to avoid invalidating an iterator. This fixes PR4977.
All clang tests now pass with expensive checking (on my system
at least).
llvm-svn: 81843
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/IPA/CallGraph.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/IPA/CallGraph.cpp b/llvm/lib/Analysis/IPA/CallGraph.cpp index 645916e35e7..e2b288d1ba9 100644 --- a/llvm/lib/Analysis/IPA/CallGraph.cpp +++ b/llvm/lib/Analysis/IPA/CallGraph.cpp @@ -279,5 +279,22 @@ void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee) { } } +/// replaceCallEdge - This method replaces the edge in the node for the +/// specified call site with a new one. Note that this method takes linear +/// time, so it should be used sparingly. +void CallGraphNode::replaceCallEdge(CallSite CS, + CallSite NewCS, CallGraphNode *NewNode){ + for (CalledFunctionsVector::iterator I = CalledFunctions.begin(); ; ++I) { + assert(I != CalledFunctions.end() && "Cannot find callsite to remove!"); + if (I->first == CS.getInstruction()) { + I->second->DropRef(); + I->first = NewCS.getInstruction(); + I->second = NewNode; + NewNode->AddRef(); + return; + } + } +} + // Enuse that users of CallGraph.h also link with this file DEFINING_FILE_FOR(CallGraph) |

