mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 23:25:06 +00:00
avoid using iterators when they get invalidated potentially
this fixes PR3332 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62271 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -155,8 +155,18 @@ static void UpdateCallGraphAfterInlining(CallSite CS,
|
|||||||
|
|
||||||
// Since we inlined some uninlined call sites in the callee into the caller,
|
// 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.
|
// add edges from the caller to all of the callees of the callee.
|
||||||
for (CallGraphNode::iterator I = CalleeNode->begin(),
|
CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end();
|
||||||
E = CalleeNode->end(); I != E; ++I) {
|
|
||||||
|
// 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();
|
const Instruction *OrigCall = I->first.getInstruction();
|
||||||
|
|
||||||
DenseMap<const Value*, Value*>::iterator VMI = ValueMap.find(OrigCall);
|
DenseMap<const Value*, Value*>::iterator VMI = ValueMap.find(OrigCall);
|
||||||
@@ -514,8 +524,8 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
|||||||
TheCall->replaceAllUsesWith(PHI);
|
TheCall->replaceAllUsesWith(PHI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all of the return instructions adding entries to the PHI node as
|
// Loop over all of the return instructions adding entries to the PHI node
|
||||||
// appropriate.
|
// as appropriate.
|
||||||
if (PHI) {
|
if (PHI) {
|
||||||
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
|
||||||
ReturnInst *RI = Returns[i];
|
ReturnInst *RI = Returns[i];
|
||||||
|
Reference in New Issue
Block a user