/// inherit from.
///
template <class NodeT>
/// inherit from.
///
template <class NodeT>
-class DominatorBase : public FunctionPass {
protected:
std::vector<NodeT*> Roots;
const bool IsPostDominators;
protected:
std::vector<NodeT*> 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
public:
/// getRoots - Return the root blocks of the current CFG. This may include
- DominatorTreeBase(intptr_t ID, bool isPostDom)
- : DominatorBase<NodeT>(ID, isPostDom), DFSInfoValid(false), SlowQueries(0) {}
- ~DominatorTreeBase() { reset(); }
+ DominatorTreeBase(bool isPostDom)
+ : DominatorBase<NodeT>(isPostDom), DFSInfoValid(false), SlowQueries(0) {}
+ virtual ~DominatorTreeBase() { reset(); }
// FIXME: Should remove this
virtual bool runOnFunction(Function &F) { return false; }
// FIXME: Should remove this
virtual bool runOnFunction(Function &F) { return false; }
DominatorTreeBase<BasicBlock>* DT;
DominatorTree() : FunctionPass(intptr_t(&ID)) {
DominatorTreeBase<BasicBlock>* DT;
DominatorTree() : FunctionPass(intptr_t(&ID)) {
- DT = new DominatorTreeBase<BasicBlock>(intptr_t(&ID), false);
+ DT = new DominatorTreeBase<BasicBlock>(false);
/// DominanceFrontierBase - Common base class for computing forward and inverse
/// dominance frontiers for a function.
///
/// DominanceFrontierBase - Common base class for computing forward and inverse
/// dominance frontiers for a function.
///
-class DominanceFrontierBase : public DominatorBase<BasicBlock> {
+class DominanceFrontierBase : public FunctionPass {
public:
typedef std::set<BasicBlock*> DomSetType; // Dom set for a bb
typedef std::map<BasicBlock*, DomSetType> DomSetMapType; // Dom set map
protected:
DomSetMapType Frontiers;
public:
typedef std::set<BasicBlock*> DomSetType; // Dom set for a bb
typedef std::map<BasicBlock*, DomSetType> DomSetMapType; // Dom set map
protected:
DomSetMapType Frontiers;
+ std::vector<BasicBlock*> Roots;
+ const bool IsPostDominators;
+
public:
DominanceFrontierBase(intptr_t ID, bool isPostDom)
public:
DominanceFrontierBase(intptr_t ID, bool isPostDom)
- : DominatorBase<BasicBlock>(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<BasicBlock*> &getRoots() const { return Roots; }
+
+ /// isPostDominator - Returns true if analysis based of postdoms
+ ///
+ bool isPostDominator() const { return IsPostDominators; }
virtual void releaseMemory() { Frontiers.clear(); }
virtual void releaseMemory() { Frontiers.clear(); }
DominatorTreeBase<BasicBlock>* DT;
PostDominatorTree() : FunctionPass((intptr_t)&ID) {
DominatorTreeBase<BasicBlock>* DT;
PostDominatorTree() : FunctionPass((intptr_t)&ID) {
- DT = new DominatorTreeBase<BasicBlock>(intptr_t(&ID), true);
+ DT = new DominatorTreeBase<BasicBlock>(true);
}
virtual bool runOnFunction(Function &F);
}
virtual bool runOnFunction(Function &F);