aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-12 22:35:13 +0000
committerChris Lattner <sabre@nondot.org>2003-05-12 22:35:13 +0000
commita3c58f1c060bb97371ad06bf10c4836845e0f5a3 (patch)
treea7a1ed217b6f32839133323d058a48879c5e68ab
parentb17a67807a63754575f0e5259521df10a50dd2e8 (diff)
downloadexternal_llvm-a3c58f1c060bb97371ad06bf10c4836845e0f5a3.zip
external_llvm-a3c58f1c060bb97371ad06bf10c4836845e0f5a3.tar.gz
external_llvm-a3c58f1c060bb97371ad06bf10c4836845e0f5a3.tar.bz2
Fix bug: Dominators/2003-05-12-UnreachableCode.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6158 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/Dominators.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index a9479aa..be9984b 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -51,16 +51,25 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) {
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];
-
- for (++PI; PI != PEnd; ++PI) { // Intersect all of the predecessor sets
- DomSetType &PredSet = Doms[*PI];
- if (PredSet.size())
- set_intersect(WorkingSet, PredSet);
- }
+ while (PI != PEnd && Doms[*PI].empty()) ++PI;
+ if (PI != PEnd) { // Not unreachable code case?
+ WorkingSet = Doms[*PI];
+
+ // 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