1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

simpler solution to iterator invalidation "problem" found

by expensive checking.

llvm-svn: 80695
This commit is contained in:
Chris Lattner 2009-09-01 18:13:40 +00:00
parent 2c2c37b2b1
commit 341df26dd9

View File

@ -143,16 +143,11 @@ void CGPassManager::RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC,
// Walk the function body looking for call sites. Sync up the call sites in // Walk the function body looking for call sites. Sync up the call sites in
// CGN with those actually in the function. // CGN with those actually in the function.
// Get the set of call sites currently in the function. // Get the set of call sites currently in the function.
bool isLast = CGN->empty(); for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != E; ){
for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(), N; !isLast;){
// Take care not to use singular iterators.
N = I + 1;
isLast = N == E;
// If this call site is null, then the function pass deleted the call // If this call site is null, then the function pass deleted the call
// entirely and the WeakVH nulled it out. // entirely and the WeakVH nulled it out.
if (I->first == 0 || if (I->first == 0 ||
// If we've already seen this call site, then the FunctionPass RAUW'd // If we've already seen this call site, then the FunctionPass RAUW'd
// one call with another, which resulted in two "uses" in the edge // one call with another, which resulted in two "uses" in the edge
@ -168,13 +163,13 @@ void CGPassManager::RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC,
E = CGN->end(); E = CGN->end();
continue; continue;
} }
assert(!CallSites.count(I->first) && assert(!CallSites.count(I->first) &&
"Call site occurs in node multiple times"); "Call site occurs in node multiple times");
CallSites.insert(std::make_pair(I->first, I->second)); CallSites.insert(std::make_pair(I->first, I->second));
I = N; ++I;
} }
// Loop over all of the instructions in the function, getting the callsites. // Loop over all of the instructions in the function, getting the callsites.
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {