[llvm-commits] [llvm] r62271 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Gabor Greif
ggreif at gmail.com
Thu Jan 15 10:40:09 PST 2009
Author: ggreif
Date: Thu Jan 15 12:40:09 2009
New Revision: 62271
URL: http://llvm.org/viewvc/llvm-project?rev=62271&view=rev
Log:
avoid using iterators when they get invalidated potentially
this fixes PR3332
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=62271&r1=62270&r2=62271&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Thu Jan 15 12:40:09 2009
@@ -155,8 +155,18 @@
// Since we inlined some uninlined call sites in the callee into the caller,
// add edges from the caller to all of the callees of the callee.
- for (CallGraphNode::iterator I = CalleeNode->begin(),
- E = CalleeNode->end(); I != E; ++I) {
+ CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end();
+
+ // Consider the case where CalleeNode == CallerNode.
+ typedef std::pair<CallSite, CallGraphNode*> CallRecord;
+ std::vector<CallRecord> CallCache;
+ if (CalleeNode == CallerNode) {
+ CallCache.assign(I, E);
+ I = CallCache.begin();
+ E = CallCache.end();
+ }
+
+ for (; I != E; ++I) {
const Instruction *OrigCall = I->first.getInstruction();
DenseMap<const Value*, Value*>::iterator VMI = ValueMap.find(OrigCall);
@@ -514,8 +524,8 @@
TheCall->replaceAllUsesWith(PHI);
}
- // Loop over all of the return instructions adding entries to the PHI node as
- // appropriate.
+ // Loop over all of the return instructions adding entries to the PHI node
+ // as appropriate.
if (PHI) {
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
ReturnInst *RI = Returns[i];
More information about the llvm-commits
mailing list