Optimizer: Do not accidentally set schedule to NULL

In case the domain of a statement is empty, the schedule optimizer set by
accident the schedule to a NULL pointer. This is incorrect. Instead, we set
it to an empty isl_map with zero schedule dimensions. We already checked for
this in our test cases, but unfortunately the test cases did not fail as
expected. The assert we add in this commit now ensures that the test cases
fail properly in case we regress on this again.

llvm-svn: 201886
This commit is contained in:
Tobias Grosser 2014-02-21 20:51:36 +00:00
parent 40066cce00
commit 34f0613562
2 changed files with 2 additions and 9 deletions

View File

@ -500,6 +500,7 @@ void ScopStmt::restrictDomain(__isl_take isl_set *NewDomain) {
}
void ScopStmt::setScattering(isl_map *NewScattering) {
assert(NewScattering && "New scattering is NULL");
isl_map_free(Scattering);
Scattering = NewScattering;
}

View File

@ -544,15 +544,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
StmtBand = isl_union_map_intersect_domain(isl_union_map_copy(ScheduleMap),
isl_union_set_from_set(Domain));
if (isl_union_map_is_empty(StmtBand)) {
// 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.
StmtSchedule = Stmt->getScattering();
StmtSchedule = isl_map_set_tuple_id(StmtSchedule, isl_dim_out, NULL);
StmtSchedule = isl_map_from_domain(isl_set_empty(Stmt->getDomainSpace()));
isl_union_map_free(StmtBand);
} else {
assert(isl_union_map_n_map(StmtBand) == 1);