[llvm-commits] [llvm] r135534 - in /llvm/trunk: lib/Transforms/Utils/BreakCriticalEdges.cpp test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll
Eli Friedman
eli.friedman at gmail.com
Tue Jul 19 15:59:41 PDT 2011
Author: efriedma
Date: Tue Jul 19 17:59:41 2011
New Revision: 135534
URL: http://llvm.org/viewvc/llvm-project?rev=135534&view=rev
Log:
PR10386: Don't try to split an edge from an indirectbr.
Added:
llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll
Modified:
llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
Modified: llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=135534&r1=135533&r2=135534&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Tue Jul 19 17:59:41 2011
@@ -337,6 +337,8 @@
}
// For each unique exit block...
+ // FIXME: This code is functionally equivalent to the corresponding
+ // loop in LoopSimplify.
SmallVector<BasicBlock *, 4> ExitBlocks;
TIL->getExitBlocks(ExitBlocks);
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
@@ -348,10 +350,15 @@
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit);
I != E; ++I) {
BasicBlock *P = *I;
- if (TIL->contains(P))
+ if (TIL->contains(P)) {
+ if (isa<IndirectBrInst>(P->getTerminator())) {
+ Preds.clear();
+ break;
+ }
Preds.push_back(P);
- else
+ } else {
HasPredOutsideOfLoop = true;
+ }
}
// If there are any preds not in the loop, we'll need to split
// the edges. The Preds.empty() check is needed because a block
Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll?rev=135534&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll (added)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2011-07-19-CritEdgeBreakCrash.ll Tue Jul 19 17:59:41 2011
@@ -0,0 +1,52 @@
+; ModuleID = '<stdin>'
+; RUN: opt < %s -loop-reduce -S | FileCheck %s
+; PR10386
+
+declare i1 @foo()
+declare i8* @bar(i8*,i8*,i8*,i8*)
+
+define void @f(i64* %a,i64* %b,i64* %c,i64* %d,i64* %e,i64* %f,i64* %g) nounwind uwtable {
+entry:
+ br label %b_throw.preheader
+
+D_BREAK_LBL: ; preds = %indirectgoto
+ call i1 @foo()
+ br label %indirectgoto
+
+H_CONST_LBL: ; preds = %indirectgoto
+ call i1 @foo()
+ br label %body_failed
+
+H_MPZ_LBL: ; preds = %indirectgoto
+ %boo3 = call i1 @foo()
+ br i1 %boo3, label %body_failed, label %while.cond.i
+
+while.cond.i: ; preds = %while.body.i15795, %if.then.i15791
+ %phi = phi i64 [ %tmp20916, %while.body.i15795 ], [ 0, %H_MPZ_LBL ]
+ %tmp20916 = add i64 %phi, 1
+ %incdec.ptr.i15793 = getelementptr i64* %pc.0.lcssa.i1610719352, i64 %tmp20916
+ %boo2 = call i1 @foo()
+ br i1 %boo2, label %indirectgoto, label %while.body.i15795
+
+while.body.i15795: ; preds = %while.cond.i
+ %tmp20.i = load i64* %incdec.ptr.i15793, align 8
+ %boo1 = call i1 @foo()
+ br i1 %boo1, label %while.cond.i, label %body_failed
+
+b_throw.preheader: ; preds = %body_failed, %entry
+ call i1 @foo()
+ br label %indirectgoto
+
+body_failed:
+ %pc.0.lcssa.i1610719364 = phi i64* [ %pc.0.lcssa.i1610719352, %indirectgoto ], [ %pc.0.lcssa.i1610719352, %H_MPZ_LBL ], [ %b, %H_CONST_LBL ], [ %pc.0.lcssa.i1610719352, %while.body.i15795 ]
+ call i1 @foo()
+ br label %b_throw.preheader
+
+indirectgoto:
+ %pc.0.lcssa.i1610719352 = phi i64* [ %pc.0.lcssa.i1610719352, %D_BREAK_LBL ], [ %a, %b_throw.preheader ], [ %d, %while.cond.i ]
+ %p = call i8* @bar(i8* blockaddress(@f, %D_BREAK_LBL), i8* blockaddress(@f, %H_CONST_LBL), i8* blockaddress(@f, %H_MPZ_LBL), i8* blockaddress(@f, %body_failed) )
+ indirectbr i8* %p, [label %D_BREAK_LBL, label %H_CONST_LBL, label %H_MPZ_LBL, label %body_failed]
+}
+
+; CHECK: %p = call i8* @bar(i8* blockaddress(@f, %D_BREAK_LBL), i8* blockaddress(@f, %H_CONST_LBL), i8* blockaddress(@f, %H_MPZ_LBL), i8* blockaddress(@f, %body_failed))
+; CHECK: indirectbr i8* %p, [label %D_BREAK_LBL, label %H_CONST_LBL, label %H_MPZ_LBL, label %body_failed]
More information about the llvm-commits
mailing list