Make DomTreeBase not a FunctionPass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2007-10-23 21:42:49 +00:00
parent de09040946
commit 7feb3be0b7
2 changed files with 23 additions and 10 deletions

View File

@ -43,12 +43,12 @@ namespace llvm {
/// inherit from. /// inherit from.
/// ///
template <class NodeT> template <class NodeT>
class DominatorBase : public FunctionPass { class DominatorBase {
protected: protected:
std::vector<NodeT*> Roots; std::vector<NodeT*> Roots;
const bool IsPostDominators; const bool IsPostDominators;
inline DominatorBase(intptr_t ID, bool isPostDom) : inline DominatorBase(bool isPostDom) :
FunctionPass(ID), Roots(), IsPostDominators(isPostDom) {} Roots(), IsPostDominators(isPostDom) {}
public: public:
/// getRoots - Return the root blocks of the current CFG. This may include /// getRoots - Return the root blocks of the current CFG. This may include
@ -293,9 +293,9 @@ protected:
} }
public: public:
DominatorTreeBase(intptr_t ID, bool isPostDom) DominatorTreeBase(bool isPostDom)
: DominatorBase<NodeT>(ID, isPostDom), DFSInfoValid(false), SlowQueries(0) {} : DominatorBase<NodeT>(isPostDom), DFSInfoValid(false), SlowQueries(0) {}
~DominatorTreeBase() { reset(); } virtual ~DominatorTreeBase() { reset(); }
// FIXME: Should remove this // FIXME: Should remove this
virtual bool runOnFunction(Function &F) { return false; } virtual bool runOnFunction(Function &F) { return false; }
@ -658,7 +658,7 @@ public:
DominatorTreeBase<BasicBlock>* DT; DominatorTreeBase<BasicBlock>* DT;
DominatorTree() : FunctionPass(intptr_t(&ID)) { DominatorTree() : FunctionPass(intptr_t(&ID)) {
DT = new DominatorTreeBase<BasicBlock>(intptr_t(&ID), false); DT = new DominatorTreeBase<BasicBlock>(false);
} }
~DominatorTree() { ~DominatorTree() {
@ -817,15 +817,28 @@ template <> struct GraphTraits<DominatorTree*>
/// DominanceFrontierBase - Common base class for computing forward and inverse /// DominanceFrontierBase - Common base class for computing forward and inverse
/// dominance frontiers for a function. /// dominance frontiers for a function.
/// ///
class DominanceFrontierBase : public DominatorBase<BasicBlock> { class DominanceFrontierBase : public FunctionPass {
public: public:
typedef std::set<BasicBlock*> DomSetType; // Dom set for a bb typedef std::set<BasicBlock*> DomSetType; // Dom set for a bb
typedef std::map<BasicBlock*, DomSetType> DomSetMapType; // Dom set map typedef std::map<BasicBlock*, DomSetType> DomSetMapType; // Dom set map
protected: protected:
DomSetMapType Frontiers; DomSetMapType Frontiers;
std::vector<BasicBlock*> Roots;
const bool IsPostDominators;
public: public:
DominanceFrontierBase(intptr_t ID, bool isPostDom) 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(); }

View File

@ -26,7 +26,7 @@ struct PostDominatorTree : public FunctionPass {
DominatorTreeBase<BasicBlock>* DT; DominatorTreeBase<BasicBlock>* DT;
PostDominatorTree() : FunctionPass((intptr_t)&ID) { 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);