diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-25 06:38:58 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-25 06:38:58 +0000 |
commit | fe0f0187be88afc697514c0626fa2c4ba87b7466 (patch) | |
tree | cea1b94f231ddf3f4952cf8d1420214f61a8249b /lib | |
parent | 64b54708667aef1ec4a0e19067f89876f7dde048 (diff) | |
download | llvm-fe0f0187be88afc697514c0626fa2c4ba87b7466.tar.gz llvm-fe0f0187be88afc697514c0626fa2c4ba87b7466.tar.bz2 llvm-fe0f0187be88afc697514c0626fa2c4ba87b7466.tar.xz |
[LCG] Now that the loop structure of the core SCC finding routine is
factored into a more reasonable form, replace the tail call with
a simple outer-loop continuation. It's sad that C++ makes this so
awkward to write, but it seems more direct and clear than the tail call
at this point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/LazyCallGraph.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp index 2e4fad3996..c9cc0dd4ec 100644 --- a/lib/Analysis/LazyCallGraph.cpp +++ b/lib/Analysis/LazyCallGraph.cpp @@ -449,6 +449,7 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() { assert(N->DFSNumber != 0 && "We should always assign a DFS number " "before placing a node onto the stack."); + bool Recurse = false; // Used to simulate recursing onto a child. for (auto I = DFSStack.back().second, E = N->end(); I != E; ++I) { Node &ChildN = *I; if (ChildN.DFSNumber == 0) { @@ -463,7 +464,8 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() { ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++; SCCEntryNodes.remove(&ChildN.getFunction()); DFSStack.push_back(std::make_pair(&ChildN, ChildN.begin())); - return LazyCallGraph::getNextSCCInPostOrder(); + Recurse = true; + break; } // Track the lowest link of the childen, if any are still in the stack. @@ -472,6 +474,11 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() { if (ChildN.LowLink >= 0 && ChildN.LowLink < N->LowLink) N->LowLink = ChildN.LowLink; } + if (Recurse) + // Continue the outer loop when we exit the inner loop in order to + // recurse onto a child. + continue; + // No more children to process here, pop the node off the stack. DFSStack.pop_back(); |