[FIX] Do not crash in the presence of infinite loops.

llvm-svn: 251870
This commit is contained in:
Johannes Doerfert 2015-11-03 00:28:07 +00:00
parent 907456fe04
commit dca2837b76
2 changed files with 103 additions and 1 deletions

View File

@ -3125,7 +3125,16 @@ void Scop::buildSchedule(
isl_schedule_insert_partial_schedule(LSchedulePair.first, MUPA);
auto *PL = L->getParentLoop();
assert(LoopSchedules.count(PL));
// Either we have a proper loop and we also build a schedule for the
// parent loop or we have a infinite loop that does not have a proper
// parent loop. In the former case this conditional will be skipped, in
// the latter case however we will break here as we do not build a domain
// nor a schedule for a infinite loop.
assert(LoopSchedules.count(PL) || LSchedulePair.first == nullptr);
if (!LoopSchedules.count(PL))
break;
auto &PSchedulePair = LoopSchedules[PL];
PSchedulePair.first =
combineInSequence(PSchedulePair.first, LSchedulePair.first);

View File

@ -0,0 +1,93 @@
; RUN: opt %loadPolly -polly-process-unprofitable -analyze -polly-scops < %s
;
; This test contains a infinite loop (bb13) and crashed the domain generation
; at some point. Just verify it does not anymore.
;
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
define void @hoge() #0 {
bb:
%tmp5 = alloca [11 x [101 x i32]], align 16
br i1 false, label %bb24, label %bb6
bb6: ; preds = %bb
br label %bb8
bb7: ; preds = %bb23
unreachable
bb8: ; preds = %bb23, %bb6
%tmp9 = getelementptr inbounds [11 x [101 x i32]], [11 x [101 x i32]]* %tmp5, i64 0, i64 0, i64 0
br label %bb10
bb10: ; preds = %bb8
%tmp = load i32, i32* %tmp9, align 4
br i1 false, label %bb23, label %bb11
bb11: ; preds = %bb10
%tmp12 = load i32, i32* %tmp9, align 4
br label %bb13
bb13: ; preds = %bb13, %bb11
%tmp14 = phi i32 [ %tmp12, %bb11 ], [ %tmp19, %bb13 ]
%tmp15 = add nsw i32 %tmp14, 1
%tmp16 = sext i32 %tmp15 to i64
%tmp17 = getelementptr inbounds [11 x [101 x i32]], [11 x [101 x i32]]* %tmp5, i64 0, i64 0, i64 %tmp16
%tmp18 = load i32, i32* %tmp17, align 4
%tmp19 = add nsw i32 %tmp14, -1
%tmp20 = load i32, i32* %tmp9, align 4
%tmp21 = sext i32 %tmp20 to i64
%tmp22 = icmp slt i64 0, %tmp21
br label %bb13
bb23: ; preds = %bb10
br i1 undef, label %bb8, label %bb7
bb24: ; preds = %bb
ret void
}
define void @hoge2() #0 {
bb:
%tmp5 = alloca [11 x [101 x i32]], align 16
br i1 false, label %bb24, label %bb6
bb6: ; preds = %bb
br label %bb8
bb7: ; preds = %bb23
unreachable
bb8: ; preds = %bb23, %bb6
%tmp9 = getelementptr inbounds [11 x [101 x i32]], [11 x [101 x i32]]* %tmp5, i64 0, i64 0, i64 0
br label %bb10
bb10: ; preds = %bb8
%tmp = load i32, i32* %tmp9, align 4
br i1 false, label %bb23, label %bb11
bb11: ; preds = %bb10
%tmp12 = load i32, i32* %tmp9, align 4
br label %bb13
bb13: ; preds = %bb13, %bb11
%tmp14 = phi i32 [ %tmp12, %bb11 ], [ %tmp19, %bb13.split ]
%tmp15 = add nsw i32 %tmp14, 1
%tmp16 = sext i32 %tmp15 to i64
%tmp17 = getelementptr inbounds [11 x [101 x i32]], [11 x [101 x i32]]* %tmp5, i64 0, i64 0, i64 %tmp16
%tmp18 = load i32, i32* %tmp17, align 4
br label %bb13.split
bb13.split:
%tmp19 = add nsw i32 %tmp14, -1
%tmp20 = load i32, i32* %tmp9, align 4
%tmp21 = sext i32 %tmp20 to i64
%tmp22 = icmp slt i64 0, %tmp21
br label %bb13
bb23: ; preds = %bb10
br i1 undef, label %bb8, label %bb7
bb24: ; preds = %bb
ret void
}