RegionInfo: Do not assert if a BB is not part of the dominance tree.
authorTobias Grosser <grosser@fim.uni-passau.de>
Tue, 10 Aug 2010 09:54:35 +0000 (09:54 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Tue, 10 Aug 2010 09:54:35 +0000 (09:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110665 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/RegionInfo.cpp
test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll [new file with mode: 0644]

index 27cee76e081cf47ec975eaded15a2d472f9426ea..abc057a773a9fba3263ee44cd844c26dc853f79c 100644 (file)
@@ -136,14 +136,16 @@ bool Region::isSimple() const {
     return false;
 
   for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE;
-       ++PI)
-    if (!contains(*PI)) {
+       ++PI) {
+    BasicBlock *Pred = *PI;
+    if (DT->getNode(Pred) && !contains(Pred)) {
       if (found) {
         isSimple = false;
         break;
       }
       found = true;
     }
+  }
 
   found = false;
 
diff --git a/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll b/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll
new file mode 100644 (file)
index 0000000..218b437
--- /dev/null
@@ -0,0 +1,20 @@
+; RUN: opt -regions %s
+define i32 @main() nounwind {
+entry:
+  br label %for.cond
+
+test:
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %entry
+  br i1 true, label %for.body, label %for.end
+
+for.body:                                         ; preds = %for.cond
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret i32 0
+}