[LCG] Special case the removal of self edges. These don't impact the SCC
authorChandler Carruth <chandlerc@gmail.com>
Sat, 26 Apr 2014 03:36:37 +0000 (03:36 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 26 Apr 2014 03:36:37 +0000 (03:36 +0000)
graph in any way because we don't track edges in the SCC graph, just
nodes. This also lets us add a nice assert about the invariant that
we're working on at least a certain number of nodes within the SCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207305 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LazyCallGraph.cpp

index f7f10101ad9c6a5d5d1dc391a3f951c6eedbad52..26212880ad3fc6031333bfbcb3fbcc4b2d517b03 100644 (file)
@@ -188,6 +188,10 @@ LazyCallGraph::SCC::removeInternalEdge(LazyCallGraph &G, Node &Caller,
   SmallVector<SCC *, 1> ResultSCCs;
   ResultSCCs.push_back(this);
 
+  // Direct recursion doesn't impact the SCC graph at all.
+  if (&Caller == &Callee)
+    return ResultSCCs;
+
   // We're going to do a full mini-Tarjan's walk using a local stack here.
   int NextDFSNumber;
   SmallVector<std::pair<Node *, Node::iterator>, 4> DFSStack;
@@ -202,6 +206,8 @@ LazyCallGraph::SCC::removeInternalEdge(LazyCallGraph &G, Node &Caller,
     N->LowLink = 0;
     G.SCCMap.erase(N);
   }
+  assert(Worklist.size() > 1 && "We have to have at least two nodes to have an "
+                                "edge between them that is within the SCC.");
 
   // The callee can already reach every node in this SCC (by definition). It is
   // the only node we know will stay inside this SCC. Everything which