summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
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
commitb60f254975a387d58d2d173531c5a9d844c82c47 (patch)
tree29eec17ebbb2d09d765e35f8ac73c7b81b506fe7 /llvm/lib/Analysis
parent88b7439a8c068de725013c5fd4d7d9b12479c3f0 (diff)
downloadbcm5719-llvm-b60f254975a387d58d2d173531c5a9d844c82c47.tar.gz
bcm5719-llvm-b60f254975a387d58d2d173531c5a9d844c82c47.zip
Factor some code from the DomTree and PostDomTree calculate methods up into
each one's runOnFunction method. llvm-svn: 42563
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/PostDominatorCalculation.h18
-rw-r--r--llvm/lib/Analysis/PostDominators.cpp23
2 files changed, 23 insertions, 18 deletions
diff --git a/llvm/lib/Analysis/PostDominatorCalculation.h b/llvm/lib/Analysis/PostDominatorCalculation.h
index 5aa692eb37f..724ff795fd1 100644
--- a/llvm/lib/Analysis/PostDominatorCalculation.h
+++ b/llvm/lib/Analysis/PostDominatorCalculation.h
@@ -19,24 +19,6 @@
namespace llvm {
void PDTcalculate(PostDominatorTree& PDT, Function &F) {
- // Step #0: Scan the function looking for the root nodes of the post-dominance
- // relationships. These blocks, which have no successors, end with return and
- // unwind instructions.
- 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))
- PDT.Roots.push_back(I);
- }
-
- // Prepopulate maps so that we don't get iterator invalidation issues later.
- PDT.IDoms[I] = 0;
- PDT.DomTreeNodes[I] = 0;
- }
-
- PDT.Vertex.push_back(0);
-
// Step #1: Number blocks in depth-first order and initialize variables used
// in later stages of the algorithm.
unsigned N = 0;
diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp
index cd29749c830..0ca73882312 100644
--- a/llvm/lib/Analysis/PostDominators.cpp
+++ b/llvm/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
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud