From 17146b867f72c2ca020e2ba8b0b6cbba93a1f7c8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 1 Sep 2009 18:13:40 +0000 Subject: [PATCH] simpler solution to iterator invalidation "problem" found by expensive checking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80695 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/CallGraphSCCPass.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index beb4e6f6ad5..7e9fd300990 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -143,16 +143,11 @@ void CGPassManager::RefreshCallGraph(std::vector &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. - 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; - + for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != 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 @@ -168,13 +163,13 @@ void CGPassManager::RefreshCallGraph(std::vector &CurSCC, E = CGN->end(); continue; } - + assert(!CallSites.count(I->first) && "Call site occurs in node multiple times"); CallSites.insert(std::make_pair(I->first, I->second)); - I = N; + ++I; } - + // 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) {