Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -1371,7 +1371,7 @@ InvariantEquivClassesTy InvariantEquivClasses; /// @brief Scop constructor; invoked from ScopInfo::buildScop. - Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth); + Scop(Region &R, ScalarEvolution &SE, unsigned MaxLoopDepth); /// @brief Get or create the access function set in a BasicBlock AccFuncSetType &getOrCreateAccessFunctions(const BasicBlock *BB) { @@ -2010,7 +2010,6 @@ // The Scop std::unique_ptr scop; - isl_ctx *ctx; // Clear the context. void clear(); Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -112,7 +112,6 @@ cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory)); //===----------------------------------------------------------------------===// - // Create a sequence of two schedules. Either argument may be null and is // interpreted as the empty schedule. Can also return null if both schedules are // empty. @@ -2731,13 +2730,13 @@ return MaxLD - MinLD + 1; } -Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context, - unsigned MaxLoopDepth) +Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, unsigned MaxLoopDepth) : SE(&ScalarEvolution), R(R), IsOptimized(false), HasSingleExitEdge(R.getExitingBlock()), HasErrorBlock(false), - MaxLoopDepth(MaxLoopDepth), IslCtx(Context), Context(nullptr), + MaxLoopDepth(MaxLoopDepth), IslCtx(isl_ctx_alloc()), Context(nullptr), Affinator(this), AssumedContext(nullptr), BoundaryContext(nullptr), Schedule(nullptr) { + isl_options_set_on_error(IslCtx, ISL_ON_ERROR_ABORT); buildContext(); } @@ -2798,6 +2797,8 @@ for (const auto &IAClass : InvariantEquivClasses) isl_set_free(std::get<2>(IAClass)); + + isl_ctx_free(IslCtx); } void Scop::updateAccessDimensionality() { @@ -4126,7 +4127,7 @@ void ScopInfo::buildScop(Region &R, AssumptionCache &AC) { unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD); - scop.reset(new Scop(R, *SE, ctx, MaxLoopDepth)); + scop.reset(new Scop(R, *SE, MaxLoopDepth)); buildStmts(R, R); buildAccessFunctions(R, R); @@ -4156,15 +4157,9 @@ void ScopInfo::clear() { scop.reset(); } //===----------------------------------------------------------------------===// -ScopInfo::ScopInfo() : RegionPass(ID) { - ctx = isl_ctx_alloc(); - isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); -} +ScopInfo::ScopInfo() : RegionPass(ID) {} -ScopInfo::~ScopInfo() { - clear(); - isl_ctx_free(ctx); -} +ScopInfo::~ScopInfo() { clear(); } void ScopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired();