[polly] r314662 - [ScopBuilder] Specialize exit block handling. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 04:41:12 PDT 2017


Author: meinersbur
Date: Mon Oct  2 04:41:12 2017
New Revision: 314662

URL: http://llvm.org/viewvc/llvm-project?rev=314662&view=rev
Log:
[ScopBuilder] Specialize exit block handling. NFC.

Decouple handling of exit block PHIs and other MemoryAccesses. Exit PHIs
only need the PHI handling part of buildAccessFunctions but requires
code for skipping them in while creating other MemoryAcesses.

This change will make it easier to modify how statement MemoryAccesses
are created without considering the exit block special case.

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

Modified: polly/trunk/include/polly/ScopBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopBuilder.h?rev=314662&r1=314661&r2=314662&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Mon Oct  2 04:41:12 2017
@@ -243,10 +243,8 @@ class ScopBuilder {
   /// @param Stmt               Statement to add MemoryAccesses to.
   /// @param BB                 A basic block in @p R.
   /// @param NonAffineSubRegion The non affine sub-region @p BB is in.
-  /// @param IsExitBlock        Flag to indicate that @p BB is in the exit BB.
   void buildAccessFunctions(ScopStmt *Stmt, BasicBlock &BB,
-                            Region *NonAffineSubRegion = nullptr,
-                            bool IsExitBlock = false);
+                            Region *NonAffineSubRegion = nullptr);
 
   /// Create a new MemoryAccess object and add it to #AccFuncMap.
   ///

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=314662&r1=314661&r2=314662&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Mon Oct  2 04:41:12 2017
@@ -701,16 +701,15 @@ void ScopBuilder::buildStmts(Region &SR)
 }
 
 void ScopBuilder::buildAccessFunctions(ScopStmt *Stmt, BasicBlock &BB,
-                                       Region *NonAffineSubRegion,
-                                       bool IsExitBlock) {
+                                       Region *NonAffineSubRegion) {
   assert(
-      !Stmt == IsExitBlock &&
+      Stmt &&
       "The exit BB is the only one that cannot be represented by a statement");
-  assert(IsExitBlock || Stmt->represents(&BB));
+  assert(Stmt->represents(&BB));
 
   // We do not build access functions for error blocks, as they may contain
   // instructions we can not model.
-  if (isErrorBlock(BB, scop->getRegion(), LI, DT) && !IsExitBlock)
+  if (isErrorBlock(BB, scop->getRegion(), LI, DT))
     return;
 
   int Count = 0;
@@ -728,11 +727,7 @@ void ScopBuilder::buildAccessFunctions(S
 
     PHINode *PHI = dyn_cast<PHINode>(&Inst);
     if (PHI)
-      buildPHIAccesses(Stmt, PHI, NonAffineSubRegion, IsExitBlock);
-
-    // For the exit block we stop modeling after the last PHI node.
-    if (!PHI && IsExitBlock)
-      break;
+      buildPHIAccesses(Stmt, PHI, NonAffineSubRegion, false);
 
     if (auto MemInst = MemAccInst::dyn_cast(Inst)) {
       assert(Stmt && "Cannot build access function in non-existing statement");
@@ -749,8 +744,7 @@ void ScopBuilder::buildAccessFunctions(S
     if (!PHI && (!isa<TerminatorInst>(&Inst) || NonAffineSubRegion))
       buildScalarDependences(Stmt, &Inst);
 
-    if (!IsExitBlock)
-      buildEscapingDependences(&Inst);
+    buildEscapingDependences(&Inst);
   }
 }
 
@@ -1193,9 +1187,15 @@ void ScopBuilder::buildScop(Region &R, A
   // To handle these PHI nodes later we will now model their operands as scalar
   // accesses. Note that we do not model anything in the exit block if we have
   // an exiting block in the region, as there will not be any splitting later.
-  if (!R.isTopLevelRegion() && !scop->hasSingleExitEdge())
-    buildAccessFunctions(nullptr, *R.getExit(), nullptr,
-                         /* IsExitBlock */ true);
+  if (!R.isTopLevelRegion() && !scop->hasSingleExitEdge()) {
+    for (Instruction &Inst : *R.getExit()) {
+      PHINode *PHI = dyn_cast<PHINode>(&Inst);
+      if (!PHI)
+        break;
+
+      buildPHIAccesses(nullptr, PHI, nullptr, true);
+    }
+  }
 
   // Create memory accesses for global reads since all arrays are now known.
   auto *AF = SE.getConstant(IntegerType::getInt64Ty(SE.getContext()), 0);




More information about the llvm-commits mailing list