diff --git a/polly/lib/Transform/ScheduleOptimizer.cpp b/polly/lib/Transform/ScheduleOptimizer.cpp index 8ee2b66339adb..5a0ea3b406754 100644 --- a/polly/lib/Transform/ScheduleOptimizer.cpp +++ b/polly/lib/Transform/ScheduleOptimizer.cpp @@ -868,23 +868,14 @@ static void runIslScheduleOptimizer( SC = SC.set_validity(Validity); SC = SC.set_coincidence(Validity); - // Save error handling behavior - long MaxOperations = isl_ctx_get_max_operations(Ctx); - isl_ctx_set_max_operations(Ctx, ScheduleComputeOut); - Schedule = SC.compute_schedule(); - bool ScheduleQuota = false; - if (isl_ctx_last_error(Ctx) == isl_error_quota) { - isl_ctx_reset_error(Ctx); - LLVM_DEBUG( - dbgs() << "Schedule optimizer calculation exceeds ISL quota\n"); - ScheduleQuota = true; - } - isl_options_set_on_error(Ctx, ISL_ON_ERROR_ABORT); - isl_ctx_reset_operations(Ctx); - isl_ctx_set_max_operations(Ctx, MaxOperations); + { + IslMaxOperationsGuard MaxOpGuard(Ctx, ScheduleComputeOut); + Schedule = SC.compute_schedule(); - if (ScheduleQuota) - return; + if (MaxOpGuard.hasQuotaExceeded()) + LLVM_DEBUG( + dbgs() << "Schedule optimizer calculation exceeds ISL quota\n"); + } isl_options_set_on_error(Ctx, OnErrorStatus); diff --git a/polly/test/ScheduleOptimizer/schedule_computeout.ll b/polly/test/ScheduleOptimizer/schedule_computeout.ll index eb59f0e36ac64..acc8601a31a83 100644 --- a/polly/test/ScheduleOptimizer/schedule_computeout.ll +++ b/polly/test/ScheduleOptimizer/schedule_computeout.ll @@ -1,8 +1,8 @@ -; 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 +; 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 ; REQUIRES: asserts ; Bailout if the computations of schedule compute exceeds the max scheduling quota. -; Max compute out is initialized to 300000, Here it is set to 100000 for test purpose. +; Max compute out is initialized to 300000, Here it is set to 10000 for test purpose. target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64-unknown-linux-gnu"