[llvm] r206959 - [LCG] Add some accessor methods to the SCC to allow iterating over the

Chandler Carruth chandlerc at gmail.com
Wed Apr 23 02:57:19 PDT 2014


Author: chandlerc
Date: Wed Apr 23 04:57:18 2014
New Revision: 206959

URL: http://llvm.org/viewvc/llvm-project?rev=206959&view=rev
Log:
[LCG] Add some accessor methods to the SCC to allow iterating over the
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.

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=206959&r1=206958&r2=206959&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Wed Apr 23 04:57:18 2014
@@ -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) {





More information about the llvm-commits mailing list