[llvm] r181025 - RegionInfo: Do not crash if unreachable block is found
Tobias Grosser
grosser at fim.uni-passau.de
Fri May 3 08:48:34 PDT 2013
Author: grosser
Date: Fri May 3 10:48:34 2013
New Revision: 181025
URL: http://llvm.org/viewvc/llvm-project?rev=181025&view=rev
Log:
RegionInfo: Do not crash if unreachable block is found
Added:
llvm/trunk/test/Analysis/RegionInfo/unreachable_bb.ll
Modified:
llvm/trunk/lib/Analysis/RegionInfo.cpp
Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionInfo.cpp?rev=181025&r1=181024&r2=181025&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/RegionInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/RegionInfo.cpp Fri May 3 10:48:34 2013
@@ -114,7 +114,8 @@ void Region::replaceExitRecursive(BasicB
bool Region::contains(const BasicBlock *B) const {
BasicBlock *BB = const_cast<BasicBlock*>(B);
- assert(DT->getNode(BB) && "BB not part of the dominance tree");
+ if (!DT->getNode(BB))
+ return false;
BasicBlock *entry = getEntry(), *exit = getExit();
Added: llvm/trunk/test/Analysis/RegionInfo/unreachable_bb.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/RegionInfo/unreachable_bb.ll?rev=181025&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/RegionInfo/unreachable_bb.ll (added)
+++ llvm/trunk/test/Analysis/RegionInfo/unreachable_bb.ll Fri May 3 10:48:34 2013
@@ -0,0 +1,29 @@
+; RUN: opt -regions -analyze < %s | FileCheck %s
+
+; We should not crash if there are some bbs that are not reachable.
+define void @f() {
+entry:
+ br label %for.pre
+
+notintree: ; No predecessors!
+ br label %ret
+
+for.pre: ; preds = %entry
+ br label %for
+
+for: ; preds = %for.inc, %for.pre
+ %indvar = phi i64 [ 0, %for.pre ], [ %indvar.next, %for.inc ]
+ %exitcond = icmp ne i64 %indvar, 200
+ br i1 %exitcond, label %for.inc, label %ret
+
+for.inc: ; preds = %for
+ %indvar.next = add i64 %indvar, 1
+ br label %for
+
+ret: ; preds = %for, %notintree
+ ret void
+}
+
+; CHECK: [0] entry => <Function Return>
+; CHECK: [1] for => ret
+
More information about the llvm-commits
mailing list