diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index f1e374a20cc..7e7f1a70a3c 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -43,12 +43,12 @@ namespace llvm { /// inherit from. /// template -class DominatorBase : public FunctionPass { +class DominatorBase { protected: std::vector Roots; const bool IsPostDominators; - inline DominatorBase(intptr_t ID, bool isPostDom) : - FunctionPass(ID), Roots(), IsPostDominators(isPostDom) {} + inline DominatorBase(bool isPostDom) : + Roots(), IsPostDominators(isPostDom) {} public: /// getRoots - Return the root blocks of the current CFG. This may include @@ -293,9 +293,9 @@ protected: } public: - DominatorTreeBase(intptr_t ID, bool isPostDom) - : DominatorBase(ID, isPostDom), DFSInfoValid(false), SlowQueries(0) {} - ~DominatorTreeBase() { reset(); } + DominatorTreeBase(bool isPostDom) + : DominatorBase(isPostDom), DFSInfoValid(false), SlowQueries(0) {} + virtual ~DominatorTreeBase() { reset(); } // FIXME: Should remove this virtual bool runOnFunction(Function &F) { return false; } @@ -658,7 +658,7 @@ public: DominatorTreeBase* DT; DominatorTree() : FunctionPass(intptr_t(&ID)) { - DT = new DominatorTreeBase(intptr_t(&ID), false); + DT = new DominatorTreeBase(false); } ~DominatorTree() { @@ -817,15 +817,28 @@ template <> struct GraphTraits /// DominanceFrontierBase - Common base class for computing forward and inverse /// dominance frontiers for a function. /// -class DominanceFrontierBase : public DominatorBase { +class DominanceFrontierBase : public FunctionPass { public: typedef std::set DomSetType; // Dom set for a bb typedef std::map DomSetMapType; // Dom set map protected: DomSetMapType Frontiers; + std::vector Roots; + const bool IsPostDominators; + public: DominanceFrontierBase(intptr_t ID, bool isPostDom) - : DominatorBase(ID, isPostDom) {} + : FunctionPass(ID), IsPostDominators(isPostDom) {} + + /// getRoots - Return the root blocks of the current CFG. This may include + /// multiple blocks if we are computing post dominators. For forward + /// dominators, this will always be a single block (the entry node). + /// + inline const std::vector &getRoots() const { return Roots; } + + /// isPostDominator - Returns true if analysis based of postdoms + /// + bool isPostDominator() const { return IsPostDominators; } virtual void releaseMemory() { Frontiers.clear(); } diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index ca9f6b192a9..56e1e74d76a 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -26,7 +26,7 @@ struct PostDominatorTree : public FunctionPass { DominatorTreeBase* DT; PostDominatorTree() : FunctionPass((intptr_t)&ID) { - DT = new DominatorTreeBase(intptr_t(&ID), true); + DT = new DominatorTreeBase(true); } virtual bool runOnFunction(Function &F);