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

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 16:28:07 PST 2015


Author: jdoerfert
Date: Mon Nov  2 18:28:07 2015
New Revision: 251870

URL: http://llvm.org/viewvc/llvm-project?rev=251870&view=rev
Log:
[FIX] Do not crash in the presence of infinite loops.

Added:
    polly/trunk/test/ScopInfo/schedule-incorrectly-contructed-in-case-of-infinite-loop.ll
Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=251870&r1=251869&r2=251870&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Nov  2 18:28:07 2015
@@ -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);

Added: polly/trunk/test/ScopInfo/schedule-incorrectly-contructed-in-case-of-infinite-loop.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/schedule-incorrectly-contructed-in-case-of-infinite-loop.ll?rev=251870&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/schedule-incorrectly-contructed-in-case-of-infinite-loop.ll (added)
+++ polly/trunk/test/ScopInfo/schedule-incorrectly-contructed-in-case-of-infinite-loop.ll Mon Nov  2 18:28:07 2015
@@ -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
+}




More information about the llvm-commits mailing list