[llvm] r207042 - [LCG] Switch the primary SCC building code to use the negative low-link

Chandler Carruth chandlerc at gmail.com
Wed Apr 23 15:28:13 PDT 2014


Author: chandlerc
Date: Wed Apr 23 17:28:13 2014
New Revision: 207042

URL: http://llvm.org/viewvc/llvm-project?rev=207042&view=rev
Log:
[LCG] Switch the primary SCC building code to use the negative low-link
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.

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=207042&r1=207041&r2=207042&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Wed Apr 23 17:28:13 2014
@@ -260,7 +260,7 @@ LazyCallGraph::SCC::removeInternalEdge(L
         // 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::getNe
       }
 
       // 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.





More information about the llvm-commits mailing list