[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Devang Patel
dpatel at apple.com
Wed Sep 13 18:27:58 PDT 2006
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.73 -> 1.74
---
Log message:
Avoid recursion in assignDFSNumber(). Move def from ET-Forest.h
to Dominators.h
---
Diffs of the changes: (+33 -0)
Dominators.cpp | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.73 llvm/lib/VMCore/Dominators.cpp:1.74
--- llvm/lib/VMCore/Dominators.cpp:1.73 Sun Aug 27 17:30:17 2006
+++ llvm/lib/VMCore/Dominators.cpp Wed Sep 13 20:27:42 2006
@@ -890,6 +890,39 @@
updateDFSNumbers ();
}
+// Walk ETNode and its children using DFS algorithm and assign
+// DFSNumIn and DFSNumOut numbers for each node.
+void ETNode::assignDFSNumber(int &num) {
+
+ std::vector<ETNode *> DFSInStack;
+ std::set<ETNode *> visited;
+
+ DFSInStack.push_back(this);
+
+ visited.insert(this);
+
+ while(!DFSInStack.empty()) {
+ ETNode *Parent = DFSInStack.back();
+ DFSInStack.pop_back();
+ Parent->DFSNumIn = num++;
+ Parent->DFSNumOut = Parent->DFSNumIn + 1;
+
+ ETNode *son = Parent->Son;
+ if (son && visited.count(son) == 0) {
+
+ DFSInStack.push_back(son);
+ son->DFSNumIn = Parent->DFSNumIn + 1;
+ visited.insert(son);
+
+ for (ETNode *s = son->Right; s != son; s = s->Right) {
+ DFSInStack.push_back(s);
+ s->DFSNumIn = Parent->DFSNumIn + 1;
+ visited.insert(s);
+ }
+ }
+ }
+}
+
//===----------------------------------------------------------------------===//
// ETForestBase Implementation
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list