[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Devang Patel
dpatel at apple.com
Mon Jun 11 17:15:09 PDT 2007
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.110 -> 1.111
---
Log message:
Maintain DFS number in DomTreeNode itself.
This means now ETNodes are not useful anymore.
---
Diffs of the changes: (+37 -3)
Dominators.cpp | 40 +++++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 3 deletions(-)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.110 llvm/lib/VMCore/Dominators.cpp:1.111
--- llvm/lib/VMCore/Dominators.cpp:1.110 Mon Jun 11 18:31:22 2007
+++ llvm/lib/VMCore/Dominators.cpp Mon Jun 11 19:14:41 2007
@@ -319,9 +319,11 @@
BasicBlock *BB = *I;
DomTreeNode *BBNode = getNode(BB);
if (BBNode) {
- ETNode *ETN = BBNode->getETNode();
- if (ETN && !ETN->hasFather())
- ETN->assignDFSNumber(dfsnum);
+ if (!BBNode->getIDom())
+ BBNode->assignDFSNumber(dfsnum);
+ //ETNode *ETN = BBNode->getETNode();
+ //if (ETN && !ETN->hasFather())
+ // ETN->assignDFSNumber(dfsnum);
}
}
SlowQueries = 0;
@@ -414,6 +416,38 @@
return NULL;
}
+/// assignDFSNumber - Assign In and Out numbers while walking dominator tree
+/// in dfs order.
+void DomTreeNode::assignDFSNumber(int num) {
+ std::vector<DomTreeNode *> workStack;
+ std::set<DomTreeNode *> visitedNodes;
+
+ workStack.push_back(this);
+ visitedNodes.insert(this);
+ this->DFSNumIn = num++;
+
+ while (!workStack.empty()) {
+ DomTreeNode *Node = workStack.back();
+
+ bool visitChild = false;
+ for (std::vector<DomTreeNode*>::iterator DI = Node->begin(),
+ E = Node->end(); DI != E && !visitChild; ++DI) {
+ DomTreeNode *Child = *DI;
+ if (visitedNodes.count(Child) == 0) {
+ visitChild = true;
+ Child->DFSNumIn = num++;
+ workStack.push_back(Child);
+ visitedNodes.insert(Child);
+ }
+ }
+ if (!visitChild) {
+ // If we reach here means all children are visited
+ Node->DFSNumOut = num++;
+ workStack.pop_back();
+ }
+ }
+}
+
void DomTreeNode::setIDom(DomTreeNode *NewIDom) {
assert(IDom && "No immediate dominator?");
if (IDom != NewIDom) {
More information about the llvm-commits
mailing list