[llvm] r207213 - [LCG] During the incremental re-build of an SCC after removing an edge,

Chandler Carruth chandlerc at gmail.com
Fri Apr 25 02:08:10 PDT 2014


Author: chandlerc
Date: Fri Apr 25 04:08:10 2014
New Revision: 207213

URL: http://llvm.org/viewvc/llvm-project?rev=207213&view=rev
Log:
[LCG] During the incremental re-build of an SCC after removing an edge,
remove the nodes in the SCC from the SCC map entirely prior to the DFS
walk. This allows the SCC map to represent both the state of
not-yet-re-added-to-an-SCC and added-back-to-this-SCC independently. The
first is being missing from the SCC map, the second is mapping back to
'this'. In a subsequent commit, I'm going to use this property to
simplify the new node list for this SCC.

In theory, I think this also makes the contract for orphaning a node
from the graph slightly less confusing. Now it is also orphaned from the
SCC graph. Still, this isn't quite right either, and so I'm not adding
test cases here. I'll add test cases for the behavior of orphaning nodes
when the code *actually* supports it. The change here is mostly
incidental, my goal is simplifying the algorithm.

Modified:
    llvm/trunk/lib/Analysis/LazyCallGraph.cpp

Modified: llvm/trunk/lib/Analysis/LazyCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyCallGraph.cpp?rev=207213&r1=207212&r2=207213&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Fri Apr 25 04:08:10 2014
@@ -191,9 +191,10 @@ LazyCallGraph::SCC::removeInternalEdge(L
   SmallVector<Node *, 1> Worklist;
   Worklist.swap(Nodes);
   for (Node *N : Worklist) {
-    // Clear these to 0 while we re-run Tarjan's over the SCC.
+    // The nodes formerly in this SCC are no longer in any SCC.
     N->DFSNumber = 0;
     N->LowLink = 0;
+    G.SCCMap.erase(N);
   }
 
   // The callee can already reach every node in this SCC (by definition). It is
@@ -230,9 +231,8 @@ LazyCallGraph::SCC::removeInternalEdge(L
       Node &ChildN = *I;
       // If this child isn't currently in this SCC, no need to process it.
       // However, we do need to remove this SCC from its SCC's parent set.
-      SCC &ChildSCC = *G.SCCMap.lookup(&ChildN);
-      if (&ChildSCC != this) {
-        ChildSCC.ParentSCCs.erase(this);
+      if (SCC *ChildSCC = G.SCCMap.lookup(&ChildN)) {
+        ChildSCC->ParentSCCs.erase(this);
         continue;
       }
 
@@ -298,6 +298,7 @@ LazyCallGraph::SCC::removeInternalEdge(L
     N->DFSNumber = -1;
     N->LowLink = -1;
     Nodes.push_back(N);
+    G.SCCMap.insert(std::make_pair(N, this));
     for (Node &ChildN : *N) {
       if (NewNodes.count(&ChildN))
         continue;





More information about the llvm-commits mailing list