move ReplaceNode out of line, rename scc_iterator::fini -> isAtEnd().
authorChris Lattner <sabre@nondot.org>
Fri, 16 Apr 2010 22:59:24 +0000 (22:59 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 16 Apr 2010 22:59:24 +0000 (22:59 +0000)
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101562 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SCCIterator.h
include/llvm/CallGraphSCCPass.h
lib/Analysis/IPA/CallGraphSCCPass.cpp

index d4f5e5ac7c3cc7be2fa1e6f28a9cd42141c1f0a8..315940643d1481e1464c8397ae258165f4ed68c5 100644 (file)
@@ -138,11 +138,11 @@ public:
   typedef scc_iterator<GraphT, GT> _Self;
 
   // Provide static "constructors"...
-  static inline _Self begin(const GraphT& G) { return _Self(GT::getEntryNode(G)); }
-  static inline _Self end  (const GraphTG) { return _Self(); }
+  static inline _Self begin(const GraphT &G){return _Self(GT::getEntryNode(G));}
+  static inline _Self end  (const GraphT &G) { return _Self(); }
 
-  // Direct loop termination test (I.fini() is more efficient than I == end())
-  inline bool fini() const {
+  // Direct loop termination test: I.isAtEnd() is more efficient than I == end()
+  inline bool isAtEnd() const {
     assert(!CurrentSCC.empty() || VisitStack.empty());
     return CurrentSCC.empty();
   }
index 3cff8f2006aa3287b2b43e482b3e08806321b01c..e11b9677c74af1b39d1d8a0895ff5694ba0a3c4d 100644 (file)
@@ -93,15 +93,7 @@ public:
   
   /// ReplaceNode - This informs the SCC and the pass manager that the specified
   /// Old node has been deleted, and New is to be used in its place.
-  void ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
-    assert(Old != New && "Should not replace node with self");
-    for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
-      if (Nodes[i] == Old) {
-        Nodes[i] = New;
-        return;
-      }
-    assert(0 && "Node not in SCC");
-  }
+  void ReplaceNode(CallGraphNode *Old, CallGraphNode *New);
   
   typedef std::vector<CallGraphNode*>::const_iterator iterator;
   iterator begin() const { return Nodes.begin(); }
index 774f0d4ddf4312e28a05fd8a4deba2a6c719d370..f5d24f005f594369e6c4268bd2afcc50a4bdcc23 100644 (file)
@@ -307,18 +307,17 @@ bool CGPassManager::runOnModule(Module &M) {
   CallGraph &CG = getAnalysis<CallGraph>();
   bool Changed = doInitialization(CG);
 
-  CallGraphSCC CurSCC(this);
-  
   // Walk the callgraph in bottom-up SCC order.
-  for (scc_iterator<CallGraph*> CGI = scc_begin(&CG), E = scc_end(&CG);
-       CGI != E;) {
+  scc_iterator<CallGraph*> CGI = scc_begin(&CG);
+
+  CallGraphSCC CurSCC(&CGI);
+  while (!CGI.isAtEnd()) {
     // Copy the current SCC and increment past it so that the pass can hack
     // on the SCC if it wants to without invalidating our iterator.
     std::vector<CallGraphNode*> &NodeVec = *CGI;
     CurSCC.initialize(&NodeVec[0], &NodeVec[0]+NodeVec.size());
     ++CGI;
     
-    
     // CallGraphUpToDate - Keep track of whether the callgraph is known to be
     // up-to-date or not.  The CGSSC pass manager runs two types of passes:
     // CallGraphSCC Passes and other random function passes.  Because other
@@ -408,6 +407,17 @@ bool CGPassManager::doFinalization(CallGraph &CG) {
 // CallGraphSCC Implementation
 //===----------------------------------------------------------------------===//
 
+/// ReplaceNode - This informs the SCC and the pass manager that the specified
+/// Old node has been deleted, and New is to be used in its place.
+void CallGraphSCC::ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
+  assert(Old != New && "Should not replace node with self");
+  for (unsigned i = 0; ; ++i) {
+    assert(i != Nodes.size() && "Node not in SCC");
+    if (Nodes[i] != Old) continue;
+    Nodes[i] = New;
+    break;
+  }
+}
 
 
 //===----------------------------------------------------------------------===//