summaryrefslogtreecommitdiffstats
path: root/lib/Analysis/IPA/CallGraph.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-15 05:40:35 +0000
committerChris Lattner <sabre@nondot.org>2009-09-15 05:40:35 +0000
commita51c39cc3265f5d0d5de87b4a3ef9332c83556e1 (patch)
tree66ec9d3d0df0527cbad15e8a2b07a7826b6ea039 /lib/Analysis/IPA/CallGraph.cpp
parentff1147072a0c9dbe91572bbbbf93031c6451bbae (diff)
downloadexternal_llvm-a51c39cc3265f5d0d5de87b4a3ef9332c83556e1.zip
external_llvm-a51c39cc3265f5d0d5de87b4a3ef9332c83556e1.tar.gz
external_llvm-a51c39cc3265f5d0d5de87b4a3ef9332c83556e1.tar.bz2
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/CallGraph.cpp')
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index 645916e..e2b288d 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/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)