[polly] r260821 - Use unique_ptr to manage Scop inside ScopInfo.

Hongbin Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 13 07:13:02 PST 2016


Author: ether
Date: Sat Feb 13 09:13:02 2016
New Revision: 260821

URL: http://llvm.org/viewvc/llvm-project?rev=260821&view=rev
Log:
Use unique_ptr to manage Scop inside ScopInfo.

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=260821&r1=260820&r2=260821&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sat Feb 13 09:13:02 2016
@@ -2009,7 +2009,7 @@ class ScopInfo : public RegionPass {
   ScalarEvolution *SE;
 
   // The Scop
-  Scop *scop;
+  std::unique_ptr<Scop> 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
   //@{

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=260821&r1=260820&r2=260821&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sat Feb 13 09:13:02 2016
@@ -4126,7 +4126,7 @@ void ScopInfo::addPHIReadAccess(PHINode
 
 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, co
   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, RG
 
   if (scop->isEmpty() || !scop->hasFeasibleRuntimeContext()) {
     Msg = "SCoP ends here but was dismissed.";
-    delete scop;
-    scop = nullptr;
+    scop.reset();
   } else {
     Msg = "SCoP ends here.";
     ++ScopFound;




More information about the llvm-commits mailing list