[llvm] r207147 - [LCG] Switch a weird do/while loop that actually couldn't fail its

Chandler Carruth chandlerc at gmail.com
Thu Apr 24 14:19:30 PDT 2014

Author: chandlerc
Date: Thu Apr 24 16:19:30 2014
New Revision: 207147

URL: http://llvm.org/viewvc/llvm-project?rev=207147&view=rev
[LCG] Switch a weird do/while loop that actually couldn't fail its
condition into an obviously infinite loop with an assert about the
degenerate condition. No functionality changed.


Modified: llvm/trunk/lib/Analysis/LazyCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyCallGraph.cpp?rev=207147&r1=207146&r2=207147&view=diff
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Thu Apr 24 16:19:30 2014
@@ -444,7 +444,7 @@ LazyCallGraph::SCC *LazyCallGraph::getNe
     DFSStack.push_back(std::make_pair(&N, N.begin()));
-  do {
+  for (;;) {
     Node *N = DFSStack.back().first;
     assert(N->DFSNumber != 0 && "We should always assign a DFS number "
                                 "before placing a node onto the stack.");
@@ -479,16 +479,15 @@ LazyCallGraph::SCC *LazyCallGraph::getNe
       // Form the new SCC out of the top of the DFS stack.
       return formSCC(N, PendingSCCStack);
+    assert(!DFSStack.empty() && "We never found a viable root!");
     // At this point we know that N cannot ever be an SCC root. Its low-link
     // is not its dfs-number, and we've processed all of its children. It is
     // just sitting here waiting until some node further down the stack gets
     // low-link == dfs-number and pops it off as well. Move it to the pending
     // stack which is pulled into the next SCC to be formed.
-  } while (!DFSStack.empty());
-  llvm_unreachable(
-      "We cannot reach the bottom of the stack without popping an SCC.");
+  }
 char LazyCallGraphAnalysis::PassID;

More information about the llvm-commits mailing list