summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-05-01 12:12:42 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-05-01 12:12:42 +0000
commit4b096741b4f2d0372cc307873edbace5cc18cda8 (patch)
treeb2a33c31137690566660676f49342c2b1f4ecd51 /llvm/lib
parent80070b5598d068325701b886e43506a844dc7307 (diff)
downloadbcm5719-llvm-4b096741b4f2d0372cc307873edbace5cc18cda8.tar.gz
bcm5719-llvm-4b096741b4f2d0372cc307873edbace5cc18cda8.zip
[LCG] Add some basic methods for querying the parent/child relationships
of SCCs in the SCC DAG. Exercise them in the big graph test case. These will be especially useful for establishing invariants in insertion logic. llvm-svn: 207749
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index 6c4574f867c..f88fc79fbd7 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -162,6 +162,21 @@ void LazyCallGraph::SCC::insert(Node &N) {
G->SCCMap[&N] = this;
}
+bool LazyCallGraph::SCC::isDescendantOf(const SCC &C) const {
+ // Walk up the parents of this SCC and verify that we eventually find C.
+ SmallVector<const SCC *, 4> AncestorWorklist;
+ AncestorWorklist.push_back(this);
+ do {
+ const SCC *AncestorC = AncestorWorklist.pop_back_val();
+ if (AncestorC->isChildOf(C))
+ return true;
+ for (const SCC *ParentC : AncestorC->ParentSCCs)
+ AncestorWorklist.push_back(ParentC);
+ } while (!AncestorWorklist.empty());
+
+ return false;
+}
+
void LazyCallGraph::SCC::insertIntraSCCEdge(Node &CallerN, Node &CalleeN) {
// First insert it into the caller.
CallerN.insertEdgeInternal(CalleeN);
OpenPOWER on IntegriCloud