[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth
2014-05-01 12:12:42 +00:00
parent 217b5866d1
commit b8f462501b
3 changed files with 49 additions and 0 deletions
+15
View File
@@ -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);