[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon May 12 17:36:01 PDT 2003
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.42 -> 1.43
---
Log message:
Fix bug: Dominators/2003-05-12-UnreachableCode.ll
---
Diffs of the changes:
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.42 llvm/lib/VMCore/Dominators.cpp:1.43
--- llvm/lib/VMCore/Dominators.cpp:1.42 Tue Oct 8 14:12:08 2002
+++ llvm/lib/VMCore/Dominators.cpp Mon May 12 17:35:13 2003
@@ -51,16 +51,25 @@
if (PI != PEnd) { // Is there SOME predecessor?
// Loop until we get to a predecessor that has had it's dom set filled
// in at least once. We are guaranteed to have this because we are
- // traversing the graph in DFO and have handled start nodes specially.
+ // traversing the graph in DFO and have handled start nodes specially,
+ // except when there are unreachable blocks.
//
- while (Doms[*PI].empty()) ++PI;
- WorkingSet = Doms[*PI];
+ while (PI != PEnd && Doms[*PI].empty()) ++PI;
+ if (PI != PEnd) { // Not unreachable code case?
+ WorkingSet = Doms[*PI];
- for (++PI; PI != PEnd; ++PI) { // Intersect all of the predecessor sets
- DomSetType &PredSet = Doms[*PI];
- if (PredSet.size())
- set_intersect(WorkingSet, PredSet);
- }
+ // Intersect all of the predecessor sets
+ for (++PI; PI != PEnd; ++PI) {
+ DomSetType &PredSet = Doms[*PI];
+ if (PredSet.size())
+ set_intersect(WorkingSet, PredSet);
+ }
+ } else {
+ // Otherwise this block is unreachable. it doesn't really matter what
+ // we use for the dominator set for the node...
+ //
+ WorkingSet = Doms[Root];
+ }
} else if (BB != Root) {
// If this isn't the root basic block and it has no predecessors, it
// must be an unreachable block. Fib a bit by saying that the root node
More information about the llvm-commits
mailing list