[llvm-commits] [llvm] r101562 - in /llvm/trunk: include/llvm/ADT/SCCIterator.h include/llvm/CallGraphSCCPass.h lib/Analysis/IPA/CallGraphSCCPass.cpp

Chris Lattner sabre at nondot.org
Fri Apr 16 15:59:24 PDT 2010


Author: lattner
Date: Fri Apr 16 17:59:24 2010
New Revision: 101562

URL: http://llvm.org/viewvc/llvm-project?rev=101562&view=rev
Log:
move ReplaceNode out of line, rename scc_iterator::fini -> isAtEnd().

No functionality change.

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

Modified: llvm/trunk/include/llvm/ADT/SCCIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SCCIterator.h?rev=101562&r1=101561&r2=101562&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SCCIterator.h (original)
+++ llvm/trunk/include/llvm/ADT/SCCIterator.h Fri Apr 16 17:59:24 2010
@@ -138,11 +138,11 @@
   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 GraphT& G) { 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();
   }

Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=101562&r1=101561&r2=101562&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CallGraphSCCPass.h (original)
+++ llvm/trunk/include/llvm/CallGraphSCCPass.h Fri Apr 16 17:59:24 2010
@@ -93,15 +93,7 @@
   
   /// 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(); }

Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=101562&r1=101561&r2=101562&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Fri Apr 16 17:59:24 2010
@@ -307,18 +307,17 @@
   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 @@
 // 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;
+  }
+}
 
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list