[LCG] Switch the primary SCC building code to use the negative low-link
authorChandler Carruth <chandlerc@gmail.com>
Wed, 23 Apr 2014 22:28:13 +0000 (22:28 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 23 Apr 2014 22:28:13 +0000 (22:28 +0000)
values rather than an expensive dense map query to test whether children
have already been popped into an SCC. This matches the incremental SCC
building code. I've also included the assert that I put there but
updated both of their text.

No functionality changed here.

I still don't have any great ideas for sharing the code between the two
implementations, but I may try a brute-force approach to factoring it at
some point.

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

lib/Analysis/LazyCallGraph.cpp

index 48d43ea02eaecae8c7df6a2d7174268fa96817f8..4ad637583ef15b9dbe88d77f0839c53aa90b9e6b 100644 (file)
@@ -260,7 +260,7 @@ LazyCallGraph::SCC::removeInternalEdge(LazyCallGraph &G, Node &Caller,
         // Track the lowest link of the childen, if any are still in the stack.
         // Any child not on the stack will have a LowLink of -1.
         assert(ChildN->LowLink != 0 &&
-               "Impossible with a non-zero DFS number.");
+               "Low-link must not be zero with a non-zero DFS number.");
         if (ChildN->LowLink >= 0 && ChildN->LowLink < N->LowLink)
           N->LowLink = ChildN->LowLink;
       }
@@ -465,7 +465,9 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() {
       }
 
       // Track the lowest link of the childen, if any are still in the stack.
-      if (ChildN->LowLink < N->LowLink && !SCCMap.count(&ChildN->getFunction()))
+      assert(ChildN->LowLink != 0 &&
+             "Low-link must not be zero with a non-zero DFS number.");
+      if (ChildN->LowLink >= 0 && ChildN->LowLink < N->LowLink)
         N->LowLink = ChildN->LowLink;
     }
     // No more children to process for this stack entry.