Skip to content

Commit 305cf62

Browse files
authored
[Polly] Check for ISL errors after schedule optimization (llvm#166551)
When ISL encounters an internal error, it sets the error flag, but it is not isl_error_quota that was already checked. Check for general errors and abort the schedule optimization if that happens, instead of continuing on the good path. The error occured when compiling llvm-test-suite's MultiSource/Applications/JM/lencod/leaky_bucket.c with Polly enabled. Not adding a test case because it depends on ISL internals. We do not want to a test case to depend on which version of ISL is used.
1 parent 1de55c9 commit 305cf62

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

polly/lib/Transform/ScheduleOptimizer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,24 @@ static void runIslScheduleOptimizer(
927927
walkScheduleTreeForStatistics(Schedule, 2);
928928
}
929929

930+
// Check for why any computation could have failed
930931
if (MaxOpGuard.hasQuotaExceeded()) {
931932
POLLY_DEBUG(dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
932933
return;
934+
} else if (isl_ctx_last_error(Ctx) != isl_error_none) {
935+
const char *File = isl_ctx_last_error_file(Ctx);
936+
int Line = isl_ctx_last_error_line(Ctx);
937+
const char *Msg = isl_ctx_last_error_msg(Ctx);
938+
POLLY_DEBUG(
939+
dbgs()
940+
<< "ISL reported an error during the computation of a new schedule at "
941+
<< File << ":" << Line << ": " << Msg);
942+
isl_ctx_reset_error(Ctx);
943+
return;
944+
} else if (Schedule.is_null()) {
945+
POLLY_DEBUG(dbgs() << "Schedule optimizer did not compute a new schedule "
946+
"for unknown reasons\n");
947+
return;
933948
}
934949

935950
// Skip profitability check if user transformation(s) have been applied.

0 commit comments

Comments
 (0)