[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h
Devang Patel
dpatel at apple.com
Mon Jun 11 17:15:03 PDT 2007
Changes in directory llvm/include/llvm/Analysis:
Dominators.h updated: 1.101 -> 1.102
---
Log message:
Maintain DFS number in DomTreeNode itself.
This means now ETNodes are not useful anymore.
---
Diffs of the changes: (+17 -3)
Dominators.h | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
Index: llvm/include/llvm/Analysis/Dominators.h
diff -u llvm/include/llvm/Analysis/Dominators.h:1.101 llvm/include/llvm/Analysis/Dominators.h:1.102
--- llvm/include/llvm/Analysis/Dominators.h:1.101 Mon Jun 11 18:31:22 2007
+++ llvm/include/llvm/Analysis/Dominators.h Mon Jun 11 19:14:41 2007
@@ -65,6 +65,8 @@
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 @@
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 @@
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);
More information about the llvm-commits
mailing list