summaryrefslogtreecommitdiff
path: root/lib/Analysis/PostDominators.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-10-03 03:20:17 +0000
committerOwen Anderson <resistor@mac.com>2007-10-03 03:20:17 +0000
commit471ab54df756f2f48c9146ad897672662c3f25f9 (patch)
tree8cdee7f6b6c84fda8f9d08aa7f780e9ebb0da144 /lib/Analysis/PostDominators.cpp
parent7687bd0b2bbff184586f0b4058b93d013a1ce508 (diff)
Factor some code from the DomTree and PostDomTree calculate methods up into
each one's runOnFunction method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/PostDominators.cpp')
-rw-r--r--lib/Analysis/PostDominators.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index cd29749c830..0ca73882312 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -28,6 +28,29 @@ char PostDominanceFrontier::ID = 0;
static RegisterPass<PostDominatorTree>
F("postdomtree", "Post-Dominator Tree Construction", true);
+bool PostDominatorTree::runOnFunction(Function &F) {
+ reset(); // Reset from the last time we were run...
+
+ // Initialize the roots list
+ for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+ TerminatorInst *Insn = I->getTerminator();
+ if (Insn->getNumSuccessors() == 0) {
+ // Unreachable block is not a root node.
+ if (!isa<UnreachableInst>(Insn))
+ Roots.push_back(I);
+ }
+
+ // Prepopulate maps so that we don't get iterator invalidation issues later.
+ IDoms[I] = 0;
+ DomTreeNodes[I] = 0;
+ }
+
+ Vertex.push_back(0);
+
+ PDTcalculate(*this, F);
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// PostDominanceFrontier Implementation
//===----------------------------------------------------------------------===//