diff options
author | Duncan Sands <baldrick@free.fr> | 2009-09-01 15:13:02 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2009-09-01 15:13:02 +0000 |
commit | 1f8303bfce8729447fee30ce6a4c4f998bec573c (patch) | |
tree | d253fad988e71e33c6bbab017bc324954b9f22c1 /llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp | |
parent | a19e971f0c2160d00fffb4ff59c3bbe4319974f8 (diff) | |
download | bcm5719-llvm-1f8303bfce8729447fee30ce6a4c4f998bec573c.tar.gz bcm5719-llvm-1f8303bfce8729447fee30ce6a4c4f998bec573c.zip |
Do not manipulate invalid iterators. This fixes the
llvm-gcc build when expensive checking is turned on.
llvm-svn: 80671
Diffstat (limited to 'llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp')
-rw-r--r-- | llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp index 1dec9c5b6b3..beb4e6f6ad5 100644 --- a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -143,11 +143,16 @@ void CGPassManager::RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC, // Walk the function body looking for call sites. Sync up the call sites in // CGN with those actually in the function. - + // Get the set of call sites currently in the function. - for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != E; ++I){ + bool isLast = CGN->empty(); + 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 - // entirely and the WeakVH nulled it out. + // entirely and the WeakVH nulled it out. if (I->first == 0 || // 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 @@ -161,15 +166,15 @@ void CGPassManager::RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC, // Just remove the edge from the set of callees. CGN->removeCallEdge(I); E = CGN->end(); - --I; continue; } - + assert(!CallSites.count(I->first) && "Call site occurs in node multiple times"); CallSites.insert(std::make_pair(I->first, I->second)); + I = N; } - + // 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 (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { |