From 055cf267db3ef12f213e112a2c80e721c792c2f8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 22 Apr 2010 20:42:33 +0000 Subject: add a DEBUG call so that -debug lists when CGSCCPM iterates. Fix RefreshCallGraph to use CGN->replaceCallEdge instead of hand rolling its own loop. replaceCallEdge properly maintains the reference counts of the nodes, fixing a crash exposed by the iterative callgraph stuff. llvm-svn: 102120 --- llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp index 6562e511e78..917aa990ceb 100644 --- a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -278,13 +278,7 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC, } // Update the edge target in CGN. - for (CallGraphNode::iterator I = CGN->begin(); ; ++I) { - assert(I != CGN->end() && "Didn't find call entry"); - if (I->first == CS.getInstruction()) { - I->second = CalleeNode; - break; - } - } + CGN->replaceCallEdge(CS, CS, CalleeNode); MadeChange = true; continue; } @@ -422,6 +416,9 @@ bool CGPassManager::runOnModule(Module &M) { unsigned Iteration = 0; bool DevirtualizedCall = false; do { + DEBUG(if (Iteration) + dbgs() << " SCCPASSMGR: Re-visiting SCC, iteration #" + << Iteration << '\n'); DevirtualizedCall = false; Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall); } while (Iteration++ < MaxIterations && DevirtualizedCall); -- cgit v1.2.3