[PATCH] D17237: [Refactor] Move AccFuncMap from ScopInfo into Scop

Hongbin Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 22:17:53 PST 2016


etherzhhb created this revision.
etherzhhb added reviewers: Meinersbur, jdoerfert, grosser.
etherzhhb added a subscriber: Polly.
etherzhhb set the repository for this revision to rL LLVM.
Herald added a subscriber: sanjoy.

Since the origin AccFuncMap in ScopInfo is used by the underlying Scop only, and it must stay alive until we delete the Scop. It will be better if we simply move the origin AccFuncMap in ScopInfo into the Scop class.

This patch also help making Scop become more portable, such that we can use it in a CallGraphSCC pass.


Repository:
  rL LLVM

http://reviews.llvm.org/D17237

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

Index: lib/Analysis/ScopInfo.cpp
===================================================================
--- lib/Analysis/ScopInfo.cpp
+++ lib/Analysis/ScopInfo.cpp
@@ -2731,10 +2731,9 @@
   return MaxLD - MinLD + 1;
 }
 
-Scop::Scop(Region &R, AccFuncMapType &AccFuncMap,
-           ScalarEvolution &ScalarEvolution, isl_ctx *Context,
+Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context,
            unsigned MaxLoopDepth)
-    : SE(&ScalarEvolution), R(R), AccFuncMap(AccFuncMap), IsOptimized(false),
+    : SE(&ScalarEvolution), R(R), IsOptimized(false),
       HasSingleExitEdge(R.getExitingBlock()), HasErrorBlock(false),
       MaxLoopDepth(MaxLoopDepth), IslCtx(Context), Context(nullptr),
       Affinator(this), AssumedContext(nullptr), BoundaryContext(nullptr),
@@ -3978,7 +3977,7 @@
   if (!Stmt)
     return nullptr;
 
-  AccFuncSetType &AccList = AccFuncMap[BB];
+  AccFuncSetType &AccList = scop->getOrCreateAccessFunctions(BB);
   Value *BaseAddr = BaseAddress;
   std::string BaseName = getIslCompatibleName("MemRef_", BaseAddr, "");
 
@@ -4127,7 +4126,7 @@
 
 void ScopInfo::buildScop(Region &R, AssumptionCache &AC) {
   unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD);
-  scop = new Scop(R, AccFuncMap, *SE, ctx, MaxLoopDepth);
+  scop = new Scop(R, *SE, ctx, MaxLoopDepth);
 
   buildStmts(R, R);
   buildAccessFunctions(R, R);
@@ -4155,7 +4154,6 @@
 }
 
 void ScopInfo::clear() {
-  AccFuncMap.clear();
   if (scop) {
     delete scop;
     scop = 0;
Index: include/polly/ScopInfo.h
===================================================================
--- include/polly/ScopInfo.h
+++ include/polly/ScopInfo.h
@@ -1238,8 +1238,10 @@
   /// The underlying Region.
   Region &R;
 
-  // Access function of bbs.
-  AccFuncMapType &AccFuncMap;
+  // Access function of statements (currently BasicBlocks) .
+  //
+  // This owns all the MemoryAccess objects of the Scop created in this pass.
+  AccFuncMapType AccFuncMap;
 
   /// Flag to indicate that the scheduler actually optimized the SCoP.
   bool IsOptimized;
@@ -1369,8 +1371,13 @@
   InvariantEquivClassesTy InvariantEquivClasses;
 
   /// @brief Scop constructor; invoked from ScopInfo::buildScop.
-  Scop(Region &R, AccFuncMapType &AccFuncMap, ScalarEvolution &SE, isl_ctx *ctx,
-       unsigned MaxLoopDepth);
+  Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth);
+
+  /// @brief Get or create the access function set in a BasicBlock
+  AccFuncSetType &getOrCreateAccessFunctions(const BasicBlock *BB) {
+    return AccFuncMap[BB];
+  }
+  //@}
 
   /// @brief Initialize this ScopInfo .
   void init(AliasAnalysis &AA, AssumptionCache &AC, ScopDetection &SD,
@@ -2001,12 +2008,6 @@
   /// @brief The ScalarEvolution to help building Scop.
   ScalarEvolution *SE;
 
-  // Access function of statements (currently BasicBlocks) .
-  //
-  // This owns all the MemoryAccess objects of the Scop created in this pass. It
-  // must live until #scop is deleted.
-  AccFuncMapType AccFuncMap;
-
   // The Scop
   Scop *scop;
   isl_ctx *ctx;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17237.47898.patch
Type: text/x-patch
Size: 3068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160213/67fd9e5c/attachment.bin>


More information about the llvm-commits mailing list