[llvm-commits] [llvm] r43259 - in /llvm/trunk: include/llvm/Analysis/PostDominators.h lib/Analysis/PostDominators.cpp lib/VMCore/Dominators.cpp
Owen Anderson
resistor at mac.com
Tue Oct 23 13:58:41 PDT 2007
Author: resistor
Date: Tue Oct 23 15:58:37 2007
New Revision: 43259
URL: http://llvm.org/viewvc/llvm-project?rev=43259&view=rev
Log:
Make DomTree and PostDomTree thin wrappers around DomTreeBase, rather than inheriting from it.
Modified:
llvm/trunk/include/llvm/Analysis/PostDominators.h
llvm/trunk/lib/Analysis/PostDominators.cpp
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=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/PostDominators.h (original)
+++ llvm/trunk/include/llvm/Analysis/PostDominators.h Tue Oct 23 15:58:37 2007
@@ -21,17 +21,39 @@
/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
/// compute the a post-dominator tree.
///
-struct PostDominatorTree : public DominatorTreeBase<BasicBlock> {
+struct PostDominatorTree : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
+ DominatorTreeBase<BasicBlock>* DT;
- PostDominatorTree() :
- DominatorTreeBase<BasicBlock>((intptr_t)&ID, true) {}
+ PostDominatorTree() : FunctionPass((intptr_t)&ID) {
+ DT = new DominatorTreeBase<BasicBlock>(intptr_t(&ID), true);
+ }
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
+
+ inline const std::vector<BasicBlock*> &getRoots() const {
+ return DT->getRoots();
+ }
+
+ inline DomTreeNode *getRootNode() const {
+ return DT->getRootNode();
+ }
+
+ inline DomTreeNode *operator[](BasicBlock *BB) const {
+ return DT->getNode(BB);
+ }
+
+ inline bool properlyDominates(const DomTreeNode* A, DomTreeNode* B) const {
+ return DT->properlyDominates(A, B);
+ }
+
+ inline bool properlyDominates(BasicBlock* A, BasicBlock* B) const {
+ return DT->properlyDominates(A, B);
+ }
};
Modified: llvm/trunk/lib/Analysis/PostDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PostDominators.cpp?rev=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/PostDominators.cpp (original)
+++ llvm/trunk/lib/Analysis/PostDominators.cpp Tue Oct 23 15:58:37 2007
@@ -29,25 +29,7 @@
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);
-
- Calculate<Inverse<BasicBlock*>, GraphTraits<Inverse<BasicBlock*> > >(*this, F);
+ DT->recalculate(F);
return false;
}
Modified: llvm/trunk/lib/VMCore/Dominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Dominators.cpp?rev=43259&r1=43258&r2=43259&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Dominators.cpp (original)
+++ llvm/trunk/lib/VMCore/Dominators.cpp Tue Oct 23 15:58:37 2007
@@ -57,17 +57,7 @@
E("domtree", "Dominator Tree Construction", true);
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);
-
- Calculate<BasicBlock*, GraphTraits<BasicBlock*> >(*this, F);
-
- updateDFSNumbers();
+ DT->recalculate(F);
return false;
}
More information about the llvm-commits
mailing list