summaryrefslogtreecommitdiff
path: root/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-25 06:45:06 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-25 06:45:06 +0000
commit6b168d6741862bae32ac4e4f8eab88e24afcde58 (patch)
tree1fcd877f48e7aba3d9ddf1a0725abf88c775d27e /lib/Analysis/LazyCallGraph.cpp
parentfe0f0187be88afc697514c0626fa2c4ba87b7466 (diff)
downloadllvm-6b168d6741862bae32ac4e4f8eab88e24afcde58.tar.gz
llvm-6b168d6741862bae32ac4e4f8eab88e24afcde58.tar.bz2
llvm-6b168d6741862bae32ac4e4f8eab88e24afcde58.tar.xz
[LCG] Remove a completely unnecessary loop. It wasn't even doing any
thing, just mucking up the code. I feel bad that I even wrote this loop. Very sorry. The diff is huge because of the indent change, but I promise all this is doing is realizing that the outer two loops were actually the exact same loops, and we didn't need two of them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LazyCallGraph.cpp')
-rw-r--r--lib/Analysis/LazyCallGraph.cpp114
1 files changed, 54 insertions, 60 deletions
diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp
index c9cc0dd4ec..871787154b 100644
--- a/lib/Analysis/LazyCallGraph.cpp
+++ b/lib/Analysis/LazyCallGraph.cpp
@@ -218,79 +218,73 @@ LazyCallGraph::SCC::removeInternalEdge(LazyCallGraph &G, Node &Caller,
"pending nodes from a prior walk.");
}
- // We simulate recursion by popping out of all the nested loops and
- // continuing.
- bool Recurse = false;
-
- do {
Node *N = DFSStack.back().first;
assert(N->DFSNumber != 0 && "We should always assign a DFS number "
"before placing a node onto the stack.");
- for (auto I = DFSStack.back().second, E = N->end(); I != E; ++I) {
- 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);
- continue;
- }
-
- // Check if we have reached a node in the new (known connected) set. If
- // so, the entire stack is necessarily in that set and we can re-start.
- if (NewNodes.count(&ChildN)) {
- while (!PendingSCCStack.empty())
- NewNodes.insert(PendingSCCStack.pop_back_val());
- while (!DFSStack.empty())
- NewNodes.insert(DFSStack.pop_back_val().first);
- Recurse = true;
- break;
- }
-
- if (ChildN.DFSNumber == 0) {
- // Mark that we should start at this child when next this node is the
- // top of the stack. We don't start at the next child to ensure this
- // child's lowlink is reflected.
- DFSStack.back().second = I;
-
- // Recurse onto this node via a tail call.
- ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++;
- Worklist.remove(&ChildN);
- DFSStack.push_back(std::make_pair(&ChildN, ChildN.begin()));
- Recurse = true;
- break;
- }
-
- // 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 &&
- "Low-link must not be zero with a non-zero DFS number.");
- if (ChildN.LowLink >= 0 && ChildN.LowLink < N->LowLink)
- N->LowLink = ChildN.LowLink;
+ // We simulate recursion by popping out of the nested loop and continuing.
+ bool Recurse = false;
+ for (auto I = DFSStack.back().second, E = N->end(); I != E; ++I) {
+ 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);
+ continue;
}
- if (Recurse)
+
+ // Check if we have reached a node in the new (known connected) set. If
+ // so, the entire stack is necessarily in that set and we can re-start.
+ if (NewNodes.count(&ChildN)) {
+ while (!PendingSCCStack.empty())
+ NewNodes.insert(PendingSCCStack.pop_back_val());
+ while (!DFSStack.empty())
+ NewNodes.insert(DFSStack.pop_back_val().first);
+ Recurse = true;
break;
+ }
- // No more children to process, pop it off the core DFS stack.
- DFSStack.pop_back();
+ if (ChildN.DFSNumber == 0) {
+ // Mark that we should start at this child when next this node is the
+ // top of the stack. We don't start at the next child to ensure this
+ // child's lowlink is reflected.
+ DFSStack.back().second = I;
- if (N->LowLink == N->DFSNumber) {
- ResultSCCs.push_back(G.formSCC(N, PendingSCCStack));
+ // Recurse onto this node via a tail call.
+ ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++;
+ Worklist.remove(&ChildN);
+ DFSStack.push_back(std::make_pair(&ChildN, ChildN.begin()));
+ Recurse = true;
break;
}
- assert(!DFSStack.empty() && "We shouldn't have an empty stack!");
+ // 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 &&
+ "Low-link must not be zero with a non-zero DFS number.");
+ if (ChildN.LowLink >= 0 && ChildN.LowLink < N->LowLink)
+ N->LowLink = ChildN.LowLink;
+ }
+ if (Recurse)
+ continue;
- // 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.
- PendingSCCStack.push_back(N);
- } while (!DFSStack.empty());
+ // No more children to process, pop it off the core DFS stack.
+ DFSStack.pop_back();
- // We reach here when we're going to "recurse".
+ if (N->LowLink == N->DFSNumber) {
+ ResultSCCs.push_back(G.formSCC(N, PendingSCCStack));
+ continue;
+ }
+
+ assert(!DFSStack.empty() && "We shouldn't have an empty stack!");
+
+ // 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.
+ PendingSCCStack.push_back(N);
}
// Replace this SCC with the NewNodes we collected above.