Use unique_ptr to manage Scop inside ScopInfo.

llvm-svn: 260821
This commit is contained in:
Hongbin Zheng 2016-02-13 15:13:02 +00:00
parent 660f3ccfa5
commit fec328083a
2 changed files with 7 additions and 13 deletions

View File

@ -2009,7 +2009,7 @@ class ScopInfo : public RegionPass {
ScalarEvolution *SE; ScalarEvolution *SE;
// The Scop // The Scop
Scop *scop; std::unique_ptr<Scop> scop;
isl_ctx *ctx; isl_ctx *ctx;
// Clear the context. // Clear the context.
@ -2214,8 +2214,8 @@ public:
/// @return If the current region is a valid for a static control part, /// @return If the current region is a valid for a static control part,
/// return the Polly IR representing this static control part, /// return the Polly IR representing this static control part,
/// return null otherwise. /// return null otherwise.
Scop *getScop() { return scop; } Scop *getScop() { return scop.get(); }
const Scop *getScop() const { return scop; } const Scop *getScop() const { return scop.get(); }
/// @name RegionPass interface /// @name RegionPass interface
//@{ //@{

View File

@ -4126,7 +4126,7 @@ void ScopInfo::addPHIReadAccess(PHINode *PHI) {
void ScopInfo::buildScop(Region &R, AssumptionCache &AC) { void ScopInfo::buildScop(Region &R, AssumptionCache &AC) {
unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD); unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD);
scop = new Scop(R, *SE, ctx, MaxLoopDepth); scop.reset(new Scop(R, *SE, ctx, MaxLoopDepth));
buildStmts(R, R); buildStmts(R, R);
buildAccessFunctions(R, R); buildAccessFunctions(R, R);
@ -4153,15 +4153,10 @@ void ScopInfo::print(raw_ostream &OS, const Module *) const {
scop->print(OS); scop->print(OS);
} }
void ScopInfo::clear() { void ScopInfo::clear() { scop.reset(); }
if (scop) {
delete scop;
scop = 0;
}
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
ScopInfo::ScopInfo() : RegionPass(ID), scop(0) { ScopInfo::ScopInfo() : RegionPass(ID) {
ctx = isl_ctx_alloc(); ctx = isl_ctx_alloc();
isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT); 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()) { if (scop->isEmpty() || !scop->hasFeasibleRuntimeContext()) {
Msg = "SCoP ends here but was dismissed."; Msg = "SCoP ends here but was dismissed.";
delete scop; scop.reset();
scop = nullptr;
} else { } else {
Msg = "SCoP ends here."; Msg = "SCoP ends here.";
++ScopFound; ++ScopFound;