[LCG] Add some accessor methods to the SCC to allow iterating over the
authorChandler Carruth <chandlerc@gmail.com>
Wed, 23 Apr 2014 09:57:18 +0000 (09:57 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 23 Apr 2014 09:57:18 +0000 (09:57 +0000)
parents of an SCC, and add a lookup method for finding the SCC for
a given function. These aren't used yet, but will be used shortly in
some unit tests I'm adding and are really part of the broader intended
interface for the analysis.

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

include/llvm/Analysis/LazyCallGraph.h

index ecb2f1530e08e2e7531428a2218e1248d8716b16..cf74101c6e9d69251cf400353a5f293bd6bf439c 100644 (file)
@@ -225,9 +225,17 @@ public:
 
   public:
     typedef SmallVectorImpl<Node *>::const_iterator iterator;
+    typedef SmallSetVector<SCC *, 1>::const_iterator parent_iterator;
 
     iterator begin() const { return Nodes.begin(); }
     iterator end() const { return Nodes.end(); }
+
+    parent_iterator parent_begin() const { return ParentSCCs.begin(); }
+    parent_iterator parent_end() const { return ParentSCCs.end(); }
+
+    iterator_range<parent_iterator> parents() const {
+      return iterator_range<parent_iterator>(parent_begin(), parent_end());
+    }
   };
 
   /// \brief A post-order depth-first SCC iterator over the call graph.
@@ -310,6 +318,12 @@ public:
   /// added.
   Node *lookup(const Function &F) const { return NodeMap.lookup(&F); }
 
+  /// \brief Lookup a function's SCC in the graph.
+  ///
+  /// \returns null if the function hasn't been assigned an SCC via the SCC
+  /// iterator walk.
+  SCC *lookupSCC(const Function &F) const { return SCCMap.lookup(&F); }
+
   /// \brief Get a graph node for a given function, scanning it to populate the
   /// graph data as necessary.
   Node *get(Function &F) {