[polly] [Polly] Check for ISL errors after schedule optimization (PR #166551)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 05:11:07 PST 2025
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/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.
>From e05785999bf8f1e0cf8babc16f7d7ba9a7bf6d1d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 5 Nov 2025 14:02:24 +0100
Subject: [PATCH] [Polly] Check for ISL errors
---
polly/lib/Transform/ScheduleOptimizer.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/polly/lib/Transform/ScheduleOptimizer.cpp b/polly/lib/Transform/ScheduleOptimizer.cpp
index 0888ebd7a9362..cb08397c201f2 100644
--- a/polly/lib/Transform/ScheduleOptimizer.cpp
+++ b/polly/lib/Transform/ScheduleOptimizer.cpp
@@ -927,9 +927,24 @@ static void runIslScheduleOptimizer(
walkScheduleTreeForStatistics(Schedule, 2);
}
+ // Check for why any computation could have failed
if (MaxOpGuard.hasQuotaExceeded()) {
POLLY_DEBUG(dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
return;
+ } else if (isl_ctx_last_error(Ctx) != isl_error_none) {
+ const char *File = isl_ctx_last_error_file(Ctx);
+ int Line = isl_ctx_last_error_line(Ctx);
+ const char *Msg = isl_ctx_last_error_msg(Ctx);
+ POLLY_DEBUG(
+ dbgs()
+ << "ISL reported an error during the computation of a new schedule at "
+ << File << ":" << Line << ": " << Msg);
+ isl_ctx_reset_error(Ctx);
+ return;
+ } else if (Schedule.is_null()) {
+ POLLY_DEBUG(dbgs() << "Schedule optimizer did not compute a new schedule "
+ "for unknown reasons\n");
+ return;
}
// Skip profitability check if user transformation(s) have been applied.
More information about the llvm-commits
mailing list