aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-05-01 12:18:20 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-05-01 12:18:20 +0000
commit7cc4ed8202fac742632dadfa067d3d8d2ba4302c (patch)
tree342fd1972bf54f53233a8b5ffdbe8bf98a5a776f /llvm/lib/Analysis/LazyCallGraph.cpp
parent034d0d6805fbb658f0d3fff1fef345dcd00fd358 (diff)
downloadllvm-7cc4ed8202fac742632dadfa067d3d8d2ba4302c.zip
llvm-7cc4ed8202fac742632dadfa067d3d8d2ba4302c.tar.gz
llvm-7cc4ed8202fac742632dadfa067d3d8d2ba4302c.tar.bz2
[LCG] Add the other simple edge insertion API to the call graph. This
just connects an SCC to one of its descendants directly. Not much of an impact. The last one is the hard one -- connecting an SCC to one of its ancestors, and thereby forming a cycle such that we have to merge all the SCCs participating in the cycle. llvm-svn: 207751
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-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 276956b..fbcacd8 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -187,6 +187,21 @@ void LazyCallGraph::SCC::insertIntraSCCEdge(Node &CallerN, Node &CalleeN) {
// Nothing changes about this SCC or any other.
}
+void LazyCallGraph::SCC::insertOutgoingEdge(Node &CallerN, Node &CalleeN) {
+ // First insert it into the caller.
+ CallerN.insertEdgeInternal(CalleeN);
+
+ assert(G->SCCMap.lookup(&CallerN) == this && "Caller must be in this SCC.");
+
+ SCC &CalleeC = *G->SCCMap.lookup(&CalleeN);
+ assert(&CalleeC != this && "Callee must not be in this SCC.");
+ assert(CalleeC.isDescendantOf(*this) &&
+ "Callee must be a descendant of the Caller.");
+
+ // The only change required is to add this SCC to the parent set of the callee.
+ CalleeC.ParentSCCs.insert(this);
+}
+
void LazyCallGraph::SCC::removeInterSCCEdge(Node &CallerN, Node &CalleeN) {
// First remove it from the node.
CallerN.removeEdgeInternal(CalleeN.getFunction());