llvm.org GIT mirror llvm / a3dfc64
move ReplaceNode out of line, rename scc_iterator::fini -> isAtEnd(). No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101562 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
3 changed file(s) with 21 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
137137 typedef scc_iterator _Self;
138138
139139 // Provide static "constructors"...
140 static inline _Self begin(const GraphT& G) { return _Self(GT::getEntryNode(G)); }
141 static inline _Self end (const GraphT& G) { return _Self(); }
142
143 // Direct loop termination test (I.fini() is more efficient than I == end())
144 inline bool fini() const {
140 static inline _Self begin(const GraphT &G){return _Self(GT::getEntryNode(G));}
141 static inline _Self end (const GraphT &G) { return _Self(); }
142
143 // Direct loop termination test: I.isAtEnd() is more efficient than I == end()
144 inline bool isAtEnd() const {
145145 assert(!CurrentSCC.empty() || VisitStack.empty());
146146 return CurrentSCC.empty();
147147 }
9292
9393 /// ReplaceNode - This informs the SCC and the pass manager that the specified
9494 /// Old node has been deleted, and New is to be used in its place.
95 void ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
96 assert(Old != New && "Should not replace node with self");
97 for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
98 if (Nodes[i] == Old) {
99 Nodes[i] = New;
100 return;
101 }
102 assert(0 && "Node not in SCC");
103 }
95 void ReplaceNode(CallGraphNode *Old, CallGraphNode *New);
10496
10597 typedef std::vector::const_iterator iterator;
10698 iterator begin() const { return Nodes.begin(); }
306306 CallGraph &CG = getAnalysis();
307307 bool Changed = doInitialization(CG);
308308
309 CallGraphSCC CurSCC(this);
310
311309 // Walk the callgraph in bottom-up SCC order.
312 for (scc_iterator CGI = scc_begin(&CG), E = scc_end(&CG);
313 CGI != E;) {
310 scc_iterator CGI = scc_begin(&CG);
311
312 CallGraphSCC CurSCC(&CGI);
313 while (!CGI.isAtEnd()) {
314314 // Copy the current SCC and increment past it so that the pass can hack
315315 // on the SCC if it wants to without invalidating our iterator.
316316 std::vector &NodeVec = *CGI;
317317 CurSCC.initialize(&NodeVec[0], &NodeVec[0]+NodeVec.size());
318318 ++CGI;
319
320319
321320 // CallGraphUpToDate - Keep track of whether the callgraph is known to be
322321 // up-to-date or not. The CGSSC pass manager runs two types of passes:
407406 // CallGraphSCC Implementation
408407 //===----------------------------------------------------------------------===//
409408
409 /// ReplaceNode - This informs the SCC and the pass manager that the specified
410 /// Old node has been deleted, and New is to be used in its place.
411 void CallGraphSCC::ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
412 assert(Old != New && "Should not replace node with self");
413 for (unsigned i = 0; ; ++i) {
414 assert(i != Nodes.size() && "Node not in SCC");
415 if (Nodes[i] != Old) continue;
416 Nodes[i] = New;
417 break;
418 }
419 }
410420
411421
412422 //===----------------------------------------------------------------------===//