[polly] r312115 - [ScopBuilder/ScopInfo] Move ScopStmt::buildAccessRelations to ScopBuilder. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 06:04:46 PDT 2017


Author: meinersbur
Date: Wed Aug 30 06:04:46 2017
New Revision: 312115

URL: http://llvm.org/viewvc/llvm-project?rev=312115&view=rev
Log:
[ScopBuilder/ScopInfo] Move ScopStmt::buildAccessRelations to ScopBuilder. NFC.

This method is only called in the SCoP building phase.
Therefore it fits better into ScopBuilder to separate
SCoP-construction from SCoP modeling.

This mostly mechanical change makes ScopBuilder directly access some of
ScopStmt/MemoryAccess private fields. We add ScopBuilder as a friend
class and will add proper accessor functions sometime later.

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

Modified: polly/trunk/include/polly/ScopBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopBuilder.h?rev=312115&r1=312114&r2=312115&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Wed Aug 30 06:04:46 2017
@@ -335,6 +335,9 @@ class ScopBuilder {
   /// @see MemoryKind
   void addPHIReadAccess(ScopStmt *PHIStmt, PHINode *PHI);
 
+  /// Build the access relation of all memory accesses of @p Stmt.
+  void buildAccessRelations(ScopStmt &Stmt);
+
 public:
   explicit ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
                        const DataLayout &DL, DominatorTree &DT, LoopInfo &LI,

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=312115&r1=312114&r2=312115&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Aug 30 06:04:46 2017
@@ -477,6 +477,7 @@ private:
 class MemoryAccess {
   friend class Scop;
   friend class ScopStmt;
+  friend class ScopBuilder;
 
 public:
   /// The access type of a memory access
@@ -1315,9 +1316,6 @@ private:
   /// Fill NestLoops with loops surrounding this statement.
   void collectSurroundingLoops();
 
-  /// Build the access relation of all memory accesses.
-  void buildAccessRelations();
-
   /// Detect and mark reductions in the ScopStmt
   void checkForReductions();
 

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=312115&r1=312114&r2=312115&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Wed Aug 30 06:04:46 2017
@@ -911,6 +911,27 @@ void ScopBuilder::addPHIReadAccess(ScopS
                   MemoryKind::PHI);
 }
 
+void ScopBuilder::buildAccessRelations(ScopStmt &Stmt) {
+  for (MemoryAccess *Access : Stmt.MemAccs) {
+    Type *ElementType = Access->getElementType();
+
+    MemoryKind Ty;
+    if (Access->isPHIKind())
+      Ty = MemoryKind::PHI;
+    else if (Access->isExitPHIKind())
+      Ty = MemoryKind::ExitPHI;
+    else if (Access->isValueKind())
+      Ty = MemoryKind::Value;
+    else
+      Ty = MemoryKind::Array;
+
+    auto *SAI = scop->getOrCreateScopArrayInfo(Access->getOriginalBaseAddr(),
+                                               ElementType, Access->Sizes, Ty);
+    Access->buildAccessRelation(SAI);
+    scop->addAccessData(Access);
+  }
+}
+
 #ifndef NDEBUG
 static void verifyUse(Scop *S, Use &Op, LoopInfo &LI) {
   auto PhysUse = VirtualUse::create(S, Op, &LI, false);
@@ -1050,7 +1071,7 @@ void ScopBuilder::buildScop(Region &R, A
   for (ScopStmt &Stmt : *scop) {
     Stmt.buildDomain();
     Stmt.collectSurroundingLoops();
-    Stmt.buildAccessRelations();
+    buildAccessRelations(Stmt);
 
     if (DetectReductions)
       Stmt.checkForReductions();

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=312115&r1=312114&r2=312115&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Aug 30 06:04:46 2017
@@ -1308,28 +1308,6 @@ void ScopStmt::restrictDomain(isl::set N
   Domain = NewDomain;
 }
 
-void ScopStmt::buildAccessRelations() {
-  Scop &S = *getParent();
-  for (MemoryAccess *Access : MemAccs) {
-    Type *ElementType = Access->getElementType();
-
-    MemoryKind Ty;
-    if (Access->isPHIKind())
-      Ty = MemoryKind::PHI;
-    else if (Access->isExitPHIKind())
-      Ty = MemoryKind::ExitPHI;
-    else if (Access->isValueKind())
-      Ty = MemoryKind::Value;
-    else
-      Ty = MemoryKind::Array;
-
-    auto *SAI = S.getOrCreateScopArrayInfo(Access->getOriginalBaseAddr(),
-                                           ElementType, Access->Sizes, Ty);
-    Access->buildAccessRelation(SAI);
-    S.addAccessData(Access);
-  }
-}
-
 void ScopStmt::addAccess(MemoryAccess *Access, bool Prepend) {
   Instruction *AccessInst = Access->getAccessInstruction();
 




More information about the llvm-commits mailing list