From 8d91579fa9ef63f645a6340ae06d30073ffdd4a8 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 23 Apr 2014 09:57:18 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206959 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LazyCallGraph.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index ecb2f1530e0..cf74101c6e9 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/include/llvm/Analysis/LazyCallGraph.h @@ -225,9 +225,17 @@ public: public: typedef SmallVectorImpl::const_iterator iterator; + typedef SmallSetVector::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 parents() const { + return iterator_range(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) { -- 2.34.1