[llvm] r257161 - [LCG] Re-order the lazy node iterator below the node type to make some

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 02:50:11 PST 2016


Author: chandlerc
Date: Fri Jan  8 04:50:11 2016
New Revision: 257161

URL: http://llvm.org/viewvc/llvm-project?rev=257161&view=rev
Log:
[LCG] Re-order the lazy node iterator below the node type to make some
subsequent work I'm doing not have its delta obscured by boring code
motion. NFC.

Modified:
    llvm/trunk/include/llvm/Analysis/LazyCallGraph.h

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=257161&r1=257160&r2=257161&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Fri Jan  8 04:50:11 2016
@@ -104,54 +104,10 @@ class LazyCallGraph {
 public:
   class Node;
   class SCC;
+  class iterator;
   typedef SmallVector<PointerUnion<Function *, Node *>, 4> NodeVectorT;
   typedef SmallVectorImpl<PointerUnion<Function *, Node *>> NodeVectorImplT;
 
-  /// A lazy iterator used for both the entry nodes and child nodes.
-  ///
-  /// When this iterator is dereferenced, if not yet available, a function will
-  /// be scanned for "calls" or uses of functions and its child information
-  /// will be constructed. All of these results are accumulated and cached in
-  /// the graph.
-  class iterator
-      : public iterator_adaptor_base<iterator, NodeVectorImplT::iterator,
-                                     std::forward_iterator_tag, Node> {
-    friend class LazyCallGraph;
-    friend class LazyCallGraph::Node;
-
-    LazyCallGraph *G;
-    NodeVectorImplT::iterator E;
-
-    // Build the iterator for a specific position in a node list.
-    iterator(LazyCallGraph &G, NodeVectorImplT::iterator NI,
-             NodeVectorImplT::iterator E)
-        : iterator_adaptor_base(NI), G(&G), E(E) {
-      while (I != E && I->isNull())
-        ++I;
-    }
-
-  public:
-    iterator() {}
-
-    using iterator_adaptor_base::operator++;
-    iterator &operator++() {
-      do {
-        ++I;
-      } while (I != E && I->isNull());
-      return *this;
-    }
-
-    reference operator*() const {
-      if (I->is<Node *>())
-        return *I->get<Node *>();
-
-      Function *F = I->get<Function *>();
-      Node &ChildN = G->get(*F);
-      *I = &ChildN;
-      return ChildN;
-    }
-  };
-
   /// A node in the call graph.
   ///
   /// This represents a single node. It's primary roles are to cache the list of
@@ -200,6 +156,51 @@ public:
     bool operator!=(const Node &N) const { return !operator==(N); }
   };
 
+  /// A lazy iterator used for both the entry nodes and child nodes.
+  ///
+  /// When this iterator is dereferenced, if not yet available, a function will
+  /// be scanned for "calls" or uses of functions and its child information
+  /// will be constructed. All of these results are accumulated and cached in
+  /// the graph.
+  class iterator
+      : public iterator_adaptor_base<iterator, NodeVectorImplT::iterator,
+                                     std::forward_iterator_tag, Node> {
+    friend class LazyCallGraph;
+    friend class LazyCallGraph::Node;
+
+    LazyCallGraph *G;
+    NodeVectorImplT::iterator E;
+
+    // Build the iterator for a specific position in a node list.
+    iterator(LazyCallGraph &G, NodeVectorImplT::iterator NI,
+             NodeVectorImplT::iterator E)
+        : iterator_adaptor_base(NI), G(&G), E(E) {
+      while (I != E && I->isNull())
+        ++I;
+    }
+
+  public:
+    iterator() {}
+
+    using iterator_adaptor_base::operator++;
+    iterator &operator++() {
+      do {
+        ++I;
+      } while (I != E && I->isNull());
+      return *this;
+    }
+
+    reference operator*() const {
+      if (I->is<Node *>())
+        return *I->get<Node *>();
+
+      Function *F = I->get<Function *>();
+      Node &ChildN = G->get(*F);
+      *I = &ChildN;
+      return ChildN;
+    }
+  };
+
   /// An SCC of the call graph.
   ///
   /// This represents a Strongly Connected Component of the call graph as




More information about the llvm-commits mailing list