[PATCH] D17240: [Refactor] Use unique_ptr to manage Scop inside ScopInfo.

Hongbin Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 13 00:20:11 PST 2016


etherzhhb created this revision.
etherzhhb added a reviewer: grosser.
etherzhhb added a subscriber: Polly.
etherzhhb set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

http://reviews.llvm.org/D17240

Files:
  include/polly/ScopInfo.h
  lib/Analysis/ScopInfo.cpp

Index: lib/Analysis/ScopInfo.cpp
===================================================================
--- lib/Analysis/ScopInfo.cpp
+++ lib/Analysis/ScopInfo.cpp
@@ -4126,7 +4126,7 @@
 
 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, SD->getInsnToMemAccMap());
@@ -4154,15 +4154,10 @@
   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);
 }
@@ -4208,8 +4203,7 @@
 
   if (scop->isEmpty() || !scop->hasFeasibleRuntimeContext()) {
     Msg = "SCoP ends here but was dismissed.";
-    delete scop;
-    scop = nullptr;
+    scop.reset();
   } else {
     Msg = "SCoP ends here.";
     ++ScopFound;
Index: include/polly/ScopInfo.h
===================================================================
--- include/polly/ScopInfo.h
+++ include/polly/ScopInfo.h
@@ -2009,7 +2009,7 @@
   ScalarEvolution *SE;
 
   // The Scop
-  Scop *scop;
+  std::unique_ptr<Scop> scop;
   isl_ctx *ctx;
 
   // Clear the context.
@@ -2222,8 +2222,8 @@
   /// @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
   //@{


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17240.47903.patch
Type: text/x-patch
Size: 1918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160213/562176e9/attachment.bin>


More information about the llvm-commits mailing list