From fec328083af1366635d5b5d0ef9d5945d06d82f0 Mon Sep 17 00:00:00 2001 From: Hongbin Zheng Date: Sat, 13 Feb 2016 15:13:02 +0000 Subject: [PATCH] Use unique_ptr to manage Scop inside ScopInfo. llvm-svn: 260821 --- polly/include/polly/ScopInfo.h | 6 +++--- polly/lib/Analysis/ScopInfo.cpp | 14 ++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 1b49499..4073452 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -2009,7 +2009,7 @@ class ScopInfo : public RegionPass { ScalarEvolution *SE; // The Scop - Scop *scop; + std::unique_ptr scop; isl_ctx *ctx; // Clear the context. @@ -2214,8 +2214,8 @@ public: /// @return If the current region is a valid for a static control part, /// return the Polly IR representing this static control part, /// return null otherwise. - Scop *getScop() { return scop; } - const Scop *getScop() const { return scop; } + Scop *getScop() { return scop.get(); } + const Scop *getScop() const { return scop.get(); } /// @name RegionPass interface //@{ diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 3faaa14..9d48ffb 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -4126,7 +4126,7 @@ void ScopInfo::addPHIReadAccess(PHINode *PHI) { void ScopInfo::buildScop(Region &R, AssumptionCache &AC) { unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD); - scop = new Scop(R, *SE, ctx, MaxLoopDepth); + scop.reset(new Scop(R, *SE, ctx, MaxLoopDepth)); buildStmts(R, R); buildAccessFunctions(R, R); @@ -4153,15 +4153,10 @@ void ScopInfo::print(raw_ostream &OS, const Module *) const { scop->print(OS); } -void ScopInfo::clear() { - if (scop) { - delete scop; - scop = 0; - } -} +void ScopInfo::clear() { scop.reset(); } //===----------------------------------------------------------------------===// -ScopInfo::ScopInfo() : RegionPass(ID), scop(0) { +ScopInfo::ScopInfo() : RegionPass(ID) { ctx = isl_ctx_alloc(); isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); } @@ -4207,8 +4202,7 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) { if (scop->isEmpty() || !scop->hasFeasibleRuntimeContext()) { Msg = "SCoP ends here but was dismissed."; - delete scop; - scop = nullptr; + scop.reset(); } else { Msg = "SCoP ends here."; ++ScopFound; -- 2.7.4