[polly] r179233 - ScheduleOpt: Do not crash on statements with empty iteration domains
Tobias Grosser
grosser at fim.uni-passau.de
Wed Apr 10 15:48:08 PDT 2013
Author: grosser
Date: Wed Apr 10 17:48:08 2013
New Revision: 179233
URL: http://llvm.org/viewvc/llvm-project?rev=179233&view=rev
Log:
ScheduleOpt: Do not crash on statements with empty iteration domains
Statements with an empty iteration domain may not have a schedule assigned by
the isl schedule optimizer. As Polly expects each statement to have a schedule,
we keep the old schedule for such statements.
This fixes http://llvm.org/PR15645`
Reported-by: Johannes Doerfert <johannesdoerfert at gmx.de>
Added:
polly/trunk/test/ScheduleOptimizer/2013-04-11-Empty-Domain-two.ll
Modified:
polly/trunk/lib/ScheduleOptimizer.cpp
Modified: polly/trunk/lib/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=179233&r1=179232&r2=179233&view=diff
==============================================================================
--- polly/trunk/lib/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/ScheduleOptimizer.cpp Wed Apr 10 17:48:08 2013
@@ -537,8 +537,21 @@ bool IslScheduleOptimizer::runOnScop(Sco
isl_union_map *StmtBand;
StmtBand = isl_union_map_intersect_domain(isl_union_map_copy(ScheduleMap),
isl_union_set_from_set(Domain));
- isl_map *StmtSchedule;
+ isl_map *StmtSchedule = NULL;
isl_union_map_foreach_map(StmtBand, getSingleMap, &StmtSchedule);
+
+ // Statements with an empty iteration domain may not have a schedule
+ // assigned by the isl schedule optimizer. As Polly expects each statement
+ // to have a schedule, we keep the old schedule for this statement. As
+ // there are zero iterations to execute, the content of the schedule does
+ // not matter.
+ //
+ // TODO: Consider removing such statements when constructing the scop.
+ if (!StmtSchedule) {
+ StmtSchedule = Stmt->getScattering();
+ StmtSchedule = isl_map_set_tuple_id(StmtSchedule, isl_dim_out, NULL);
+ }
+
Stmt->setScattering(StmtSchedule);
isl_union_map_free(StmtBand);
}
Added: polly/trunk/test/ScheduleOptimizer/2013-04-11-Empty-Domain-two.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScheduleOptimizer/2013-04-11-Empty-Domain-two.ll?rev=179233&view=auto
==============================================================================
--- polly/trunk/test/ScheduleOptimizer/2013-04-11-Empty-Domain-two.ll (added)
+++ polly/trunk/test/ScheduleOptimizer/2013-04-11-Empty-Domain-two.ll Wed Apr 10 17:48:08 2013
@@ -0,0 +1,24 @@
+; RUN: opt %loadPolly -polly-opt-isl -S %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Check that we handle statements with an empty iteration domain correctly.
+
+define void @f() {
+entry:
+ %A = alloca double
+ br label %for
+
+for:
+ %indvar = phi i32 [ %indvar.next, %for.inc ], [ 0, %entry ]
+ %exitcond = icmp ne i32 %indvar, -1
+ br i1 %exitcond, label %for.inc, label %return
+
+for.inc:
+ %indvar.next = add i32 %indvar, 1
+ store double 1.0, double* %A
+ br label %for
+
+return:
+ ret void
+}
More information about the llvm-commits
mailing list