Maintain DFS number in DomTreeNode itself.

This means now ETNodes are not useful anymore.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2007-06-12 00:14:41 +00:00
parent fe7d4e50b8
commit 3726b82a55
2 changed files with 54 additions and 6 deletions

View File

@@ -65,6 +65,8 @@ class DomTreeNode {
DomTreeNode *IDom;
ETNode *ETN;
std::vector<DomTreeNode*> Children;
int DFSNumIn, DFSNumOut;
public:
typedef std::vector<DomTreeNode*>::iterator iterator;
typedef std::vector<DomTreeNode*>::const_iterator const_iterator;
@@ -80,12 +82,22 @@ public:
inline const std::vector<DomTreeNode*> &getChildren() const { return Children; }
inline DomTreeNode(BasicBlock *BB, DomTreeNode *iDom, ETNode *E)
: TheBB(BB), IDom(iDom), ETN(E) {
: TheBB(BB), IDom(iDom), ETN(E), DFSNumIn(-1), DFSNumOut(-1) {
if (IDom)
ETN->setFather(IDom->getETNode());
}
inline DomTreeNode *addChild(DomTreeNode *C) { Children.push_back(C); return C; }
void setIDom(DomTreeNode *NewIDom);
// Return true if this node is dominated by other. Use this only if DFS info is valid.
bool DominatedBy(const DomTreeNode *other) const {
return this->DFSNumIn >= other->DFSNumIn &&
this->DFSNumOut <= other->DFSNumOut;
}
/// assignDFSNumber - Assign In and Out numbers while walking dominator tree
/// in dfs order.
void assignDFSNumber(int num);
};
//===----------------------------------------------------------------------===//
@@ -214,14 +226,16 @@ protected:
ETNode *NodeB = B->getETNode();
if (DFSInfoValid)
return NodeB->DominatedBy(NodeA);
return B->DominatedBy(A);
//return NodeB->DominatedBy(NodeA);
// If we end up with too many slow queries, just update the
// DFS numbers on the theory that we are going to keep querying.
SlowQueries++;
if (SlowQueries > 32) {
updateDFSNumbers();
return NodeB->DominatedBy(NodeA);
return B->DominatedBy(A);
//return NodeB->DominatedBy(NodeA);
}
//return NodeB->DominatedBySlow(NodeA);
return dominatedBySlowTreeWalk(A, B);