Skip to content

Commit 0f33c54

Browse files
authored
[polly][ScheduleOptimizer] Use IslMaxOperationsGuard helper instead of explicit restoration (llvm#79303)
To fix long compile time issue of Schedule optimizer, patch llvm#77280 sets the upper cap on max ISL operations. In case of bailing out when ISL quota is hit, error handling behavior was restored manually. This commit replaces the restoration code with IslMaxOperationsGuard helper and also removes redundant early return.
1 parent 411554a commit 0f33c54

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

polly/lib/Transform/ScheduleOptimizer.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -868,23 +868,14 @@ static void runIslScheduleOptimizer(
868868
SC = SC.set_validity(Validity);
869869
SC = SC.set_coincidence(Validity);
870870

871-
// Save error handling behavior
872-
long MaxOperations = isl_ctx_get_max_operations(Ctx);
873-
isl_ctx_set_max_operations(Ctx, ScheduleComputeOut);
874-
Schedule = SC.compute_schedule();
875-
bool ScheduleQuota = false;
876-
if (isl_ctx_last_error(Ctx) == isl_error_quota) {
877-
isl_ctx_reset_error(Ctx);
878-
LLVM_DEBUG(
879-
dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
880-
ScheduleQuota = true;
881-
}
882-
isl_options_set_on_error(Ctx, ISL_ON_ERROR_ABORT);
883-
isl_ctx_reset_operations(Ctx);
884-
isl_ctx_set_max_operations(Ctx, MaxOperations);
871+
{
872+
IslMaxOperationsGuard MaxOpGuard(Ctx, ScheduleComputeOut);
873+
Schedule = SC.compute_schedule();
885874

886-
if (ScheduleQuota)
887-
return;
875+
if (MaxOpGuard.hasQuotaExceeded())
876+
LLVM_DEBUG(
877+
dbgs() << "Schedule optimizer calculation exceeds ISL quota\n");
878+
}
888879

889880
isl_options_set_on_error(Ctx, OnErrorStatus);
890881

polly/test/ScheduleOptimizer/schedule_computeout.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
; RUN: opt %loadPolly -S -polly-optree -polly-delicm -polly-opt-isl -polly-schedule-computeout=100000 -debug-only="polly-opt-isl" < %s 2>&1 | FileCheck %s
1+
; RUN: opt %loadPolly -S -polly-optree -polly-delicm -polly-opt-isl -polly-schedule-computeout=10000 -debug-only="polly-opt-isl" < %s 2>&1 | FileCheck %s
22
; REQUIRES: asserts
33

44
; Bailout if the computations of schedule compute exceeds the max scheduling quota.
5-
; Max compute out is initialized to 300000, Here it is set to 100000 for test purpose.
5+
; Max compute out is initialized to 300000, Here it is set to 10000 for test purpose.
66

77
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
88
target triple = "aarch64-unknown-linux-gnu"

0 commit comments

Comments
 (0)