[llvm-commits] [llvm] r42563 - in /llvm/trunk: include/llvm/Analysis/PostDominators.h lib/Analysis/PostDominatorCalculation.h lib/Analysis/PostDominators.cpp lib/VMCore/DominatorCalculation.h lib/VMCore/Dominators.cpp
Owen Anderson
resistor at mac.com
Tue Oct 2 20:20:17 PDT 2007
Author: resistor
Date: Tue Oct 2 22:20:17 2007
New Revision: 42563
URL: http://llvm.org/viewvc/llvm-project?rev=42563&view=rev
Log:
Factor some code from the DomTree and PostDomTree calculate methods up into
each one's runOnFunction method.
Modified:
llvm/trunk/include/llvm/Analysis/PostDominators.h
llvm/trunk/lib/Analysis/PostDominatorCalculation.h
llvm/trunk/lib/Analysis/PostDominators.cpp
llvm/trunk/lib/VMCore/DominatorCalculation.h
llvm/trunk/lib/VMCore/Dominators.cpp
Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=42563&r1=42562&r2=42563&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/PostDominators.h (original)
+++ llvm/trunk/include/llvm/Analysis/PostDominators.h Tue Oct 2 22:20:17 2007
@@ -27,11 +27,7 @@
PostDominatorTree() :
DominatorTreeBase((intptr_t)&ID, true) {}
- virtual bool runOnFunction(Function &F) {
- reset(); // Reset from the last time we were run...
- PDTcalculate(*this, F);
- return false;
- }
+ virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
Modified: llvm/trunk/lib/Analysis/PostDominatorCalculation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PostDominatorCalculation.h?rev=42563&r1=42562&r2=42563&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/PostDominatorCalculation.h (original)
+++ llvm/trunk/lib/Analysis/PostDominatorCalculation.h Tue Oct 2 22:20:17 2007
@@ -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;
Modified: llvm/trunk/lib/Analysis/PostDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PostDominators.cpp?rev=42563&r1=42562&r2=42563&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/PostDominators.cpp (original)
+++ llvm/trunk/lib/Analysis/PostDominators.cpp Tue Oct 2 22:20:17 2007
@@ -28,6 +28,29 @@
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
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/VMCore/DominatorCalculation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DominatorCalculation.h?rev=42563&r1=42562&r2=42563&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DominatorCalculation.h (original)
+++ llvm/trunk/lib/VMCore/DominatorCalculation.h Tue Oct 2 22:20:17 2007
@@ -40,8 +40,6 @@
// Add a node for the root...
DT.DomTreeNodes[Root] = DT.RootNode = new DomTreeNode(Root, 0);
- DT.Vertex.push_back(0);
-
// Step #1: Number blocks in depth-first order and initialize variables used
// in later stages of the algorithm.
unsigned N = DFSPass<GraphTraits<BasicBlock*> >(DT, Root, 0);
Modified: llvm/trunk/lib/VMCore/Dominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=42563&r1=42562&r2=42563&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Dominators.cpp (original)
+++ llvm/trunk/lib/VMCore/Dominators.cpp Tue Oct 2 22:20:17 2007
@@ -350,7 +350,13 @@
bool DominatorTree::runOnFunction(Function &F) {
reset(); // Reset from the last time we were run...
+
+ // Initialize roots
Roots.push_back(&F.getEntryBlock());
+ IDoms[&F.getEntryBlock()] = 0;
+ DomTreeNodes[&F.getEntryBlock()] = 0;
+ Vertex.push_back(0);
+
DTcalculate(*this, F);
return false;
}
More information about the llvm-commits
mailing list