[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jun 19 15:21:01 PDT 2004
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.56 -> 1.57
---
Log message:
compute dominator tree children in a deterministic order that does not depend
on the address of BasicBlock objects in memory. This eliminates stuff like this:
Inorder Dominator Tree:
[1] %entry
[2] %loopentry
- [3] %loopexit
[3] %no_exit
- [4] %endif
[4] %then
+ [4] %endif
+ [3] %loopexit
[3] %return
---
Diffs of the changes: (+12 -11)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.56 llvm/lib/VMCore/Dominators.cpp:1.57
--- llvm/lib/VMCore/Dominators.cpp:1.56 Sat Jun 19 15:04:47 2004
+++ llvm/lib/VMCore/Dominators.cpp Sat Jun 19 15:13:48 2004
@@ -373,19 +373,20 @@
BasicBlock *Root = Roots[0];
Nodes[Root] = RootNode = new Node(Root, 0); // Add a node for the root...
+ Function *F = Root->getParent();
// Loop over all of the reachable blocks in the function...
- for (ImmediateDominators::const_iterator I = ID.begin(), E = ID.end();
- I != E; ++I) {
- Node *&BBNode = Nodes[I->first];
- if (!BBNode) { // Haven't calculated this node yet?
- // Get or calculate the node for the immediate dominator
- Node *IDomNode = getNodeForBlock(I->second);
-
- // Add a new tree node for this BasicBlock, and link it as a child of
- // IDomNode
- BBNode = IDomNode->addChild(new Node(I->first, IDomNode));
+ for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
+ if (BasicBlock *ImmDom = ID.get(I)) { // Reachable block.
+ Node *&BBNode = Nodes[I];
+ if (!BBNode) { // Haven't calculated this node yet?
+ // Get or calculate the node for the immediate dominator
+ Node *IDomNode = getNodeForBlock(ImmDom);
+
+ // Add a new tree node for this BasicBlock, and link it as a child of
+ // IDomNode
+ BBNode = IDomNode->addChild(new Node(I, IDomNode));
+ }
}
- }
}
static std::ostream &operator<<(std::ostream &o,
More information about the llvm-commits
mailing list