[llvm-commits] CVS: llvm/lib/Analysis/IPA/CallGraph.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Sep 19 12:01:19 PDT 2004
Changes in directory llvm/lib/Analysis/IPA:
CallGraph.cpp updated: 1.44 -> 1.45
---
Log message:
Fix a nasty iterator invalidation problem I introduced yesterday. This
unfortunately is the cause of a bunch of failures from tonight, and the
reason the tester is running so slow :(
---
Diffs of the changes: (+5 -5)
Index: llvm/lib/Analysis/IPA/CallGraph.cpp
diff -u llvm/lib/Analysis/IPA/CallGraph.cpp:1.44 llvm/lib/Analysis/IPA/CallGraph.cpp:1.45
--- llvm/lib/Analysis/IPA/CallGraph.cpp:1.44 Sat Sep 18 16:34:34 2004
+++ llvm/lib/Analysis/IPA/CallGraph.cpp Sun Sep 19 14:01:06 2004
@@ -211,10 +211,10 @@
// the specified callee function. This takes more time to execute than
// removeCallEdgeTo, so it should not be used unless necessary.
void CallGraphNode::removeAnyCallEdgeTo(CallGraphNode *Callee) {
- for (std::vector<CallGraphNode*>::iterator I = CalledFunctions.begin(),
- E = CalledFunctions.end(); I != E; ++I)
- if (*I == Callee) {
- CalledFunctions.erase(I);
- E = CalledFunctions.end();
+ for (unsigned i = 0, e = CalledFunctions.size(); i != e; ++i)
+ if (CalledFunctions[i] == Callee) {
+ CalledFunctions[i] = CalledFunctions.back();
+ CalledFunctions.pop_back();
+ --i; --e;
}
}
More information about the llvm-commits
mailing list