[polly] r322851 - [ScopInfo] Pass name to ScopStmt ctor. NFC.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 07:15:39 PST 2018


Author: meinersbur
Date: Thu Jan 18 07:15:38 2018
New Revision: 322851

URL: http://llvm.org/viewvc/llvm-project?rev=322851&view=rev
Log:
[ScopInfo] Pass name to ScopStmt ctor. NFC.

This will give control of the statement's name to the caller.
Required to give -polly-stmt-granularity=scalar-indep more control
over the name of the generated statement in a follow-up commit.

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopBuilder.cpp
    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=322851&r1=322850&r2=322851&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Jan 18 07:15:38 2018
@@ -1195,8 +1195,8 @@ class ScopStmt {
 
 public:
   /// Create the ScopStmt from a BasicBlock.
-  ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop,
-           std::vector<Instruction *> Instructions, int Count);
+  ScopStmt(Scop &parent, BasicBlock &bb, StringRef Name, Loop *SurroundingLoop,
+           std::vector<Instruction *> Instructions);
 
   /// Create an overapproximating ScopStmt for the region @p R.
   ///
@@ -1206,7 +1206,7 @@ public:
   ///                               blocks for now. We currently do not allow
   ///                               to modify the instructions of blocks later
   ///                               in the region statement.
-  ScopStmt(Scop &parent, Region &R, Loop *SurroundingLoop,
+  ScopStmt(Scop &parent, Region &R, StringRef Name, Loop *SurroundingLoop,
            std::vector<Instruction *> EntryBlockInstructions);
 
   /// Create a copy statement.
@@ -2197,11 +2197,11 @@ private:
   /// and map.
   ///
   /// @param BB              The basic block we build the statement for.
+  /// @param Name            The name of the new statement.
   /// @param SurroundingLoop The loop the created statement is contained in.
   /// @param Instructions    The instructions in the statement.
-  /// @param Count           The index of the created statement in @p BB.
-  void addScopStmt(BasicBlock *BB, Loop *SurroundingLoop,
-                   std::vector<Instruction *> Instructions, int Count);
+  void addScopStmt(BasicBlock *BB, StringRef Name, Loop *SurroundingLoop,
+                   std::vector<Instruction *> Instructions);
 
   /// Create a new SCoP statement for @p R.
   ///
@@ -2209,11 +2209,12 @@ private:
   /// and map.
   ///
   /// @param R                      The region we build the statement for.
+  /// @param Name                   The name of the new statement.
   /// @param SurroundingLoop        The loop the created statement is contained
   ///                               in.
   /// @param EntryBlockInstructions The (interesting) instructions in the
   ///                               entry block of the region statement.
-  void addScopStmt(Region *R, Loop *SurroundingLoop,
+  void addScopStmt(Region *R, StringRef Name, Loop *SurroundingLoop,
                    std::vector<Instruction *> EntryBlockInstructions);
 
   /// Update access dimensionalities.

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=322851&r1=322850&r2=322851&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Thu Jan 18 07:15:38 2018
@@ -19,6 +19,7 @@
 #include "polly/ScopDetection.h"
 #include "polly/ScopDetectionDiagnostic.h"
 #include "polly/ScopInfo.h"
+#include "polly/Support/GICHelper.h"
 #include "polly/Support/SCEVValidator.h"
 #include "polly/Support/ScopHelper.h"
 #include "polly/Support/VirtualInstruction.h"
@@ -688,6 +689,28 @@ bool ScopBuilder::shouldModelInst(Instru
          !canSynthesize(Inst, *scop, &SE, L);
 }
 
+/// Generate a name for a statement.
+///
+/// @param S     The parent SCoP.
+/// @param BB    The basic block the statement will represent.
+/// @param Count The index of the created statement in @p BB.
+static std::string makeStmtName(Scop *S, BasicBlock *BB, int Count) {
+  std::string Suffix = "";
+  if (Count != 0)
+    Suffix += std::to_string(Count);
+  return getIslCompatibleName("Stmt", BB, S->getNextStmtIdx(), Suffix,
+                              UseInstructionNames);
+}
+
+/// Generate a name for a statement that represents a non-affine subregion.
+///
+/// @param S The parent SCoP.
+/// @param R The region the statement will represent.
+static std::string makeStmtName(Scop *S, Region *R) {
+  return getIslCompatibleName("Stmt", R->getNameStr(), S->getNextStmtIdx(), "",
+                              UseInstructionNames);
+}
+
 void ScopBuilder::buildSequentialBlockStmts(BasicBlock *BB, bool SplitOnStore) {
   Loop *SurroundingLoop = LI.getLoopFor(BB);
 
@@ -698,13 +721,15 @@ void ScopBuilder::buildSequentialBlockSt
       Instructions.push_back(&Inst);
     if (Inst.getMetadata("polly_split_after") ||
         (SplitOnStore && isa<StoreInst>(Inst))) {
-      scop->addScopStmt(BB, SurroundingLoop, Instructions, Count);
+      std::string Name = makeStmtName(scop.get(), BB, Count);
+      scop->addScopStmt(BB, Name, SurroundingLoop, Instructions);
       Count++;
       Instructions.clear();
     }
   }
 
-  scop->addScopStmt(BB, SurroundingLoop, Instructions, Count);
+  std::string Name = makeStmtName(scop.get(), BB, Count);
+  scop->addScopStmt(BB, Name, SurroundingLoop, Instructions);
 }
 
 /// Is @p Inst an ordered instruction?
@@ -874,7 +899,8 @@ void ScopBuilder::buildEqivClassBlockStm
   for (auto &Instructions : reverse(LeaderToInstList)) {
     std::vector<Instruction *> &InstList = Instructions.second;
     std::reverse(InstList.begin(), InstList.end());
-    scop->addScopStmt(BB, L, std::move(InstList), Count);
+    std::string Name = makeStmtName(scop.get(), BB, Count);
+    scop->addScopStmt(BB, Name, L, std::move(InstList));
     Count += 1;
   }
 }
@@ -887,7 +913,8 @@ void ScopBuilder::buildStmts(Region &SR)
     for (Instruction &Inst : *SR.getEntry())
       if (shouldModelInst(&Inst, SurroundingLoop))
         Instructions.push_back(&Inst);
-    scop->addScopStmt(&SR, SurroundingLoop, Instructions);
+    std::string Name = makeStmtName(scop.get(), &SR);
+    scop->addScopStmt(&SR, Name, SurroundingLoop, Instructions);
     return;
   }
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=322851&r1=322850&r2=322851&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Jan 18 07:15:38 2018
@@ -1695,26 +1695,19 @@ bool buildConditionSets(Scop &S, BasicBl
                             ConditionSets);
 }
 
-ScopStmt::ScopStmt(Scop &parent, Region &R, Loop *SurroundingLoop,
+ScopStmt::ScopStmt(Scop &parent, Region &R, StringRef Name,
+                   Loop *SurroundingLoop,
                    std::vector<Instruction *> EntryBlockInstructions)
     : Parent(parent), InvalidDomain(nullptr), Domain(nullptr), R(&R),
-      Build(nullptr), SurroundingLoop(SurroundingLoop),
-      Instructions(EntryBlockInstructions) {
-  BaseName = getIslCompatibleName(
-      "Stmt", R.getNameStr(), parent.getNextStmtIdx(), "", UseInstructionNames);
-}
+      Build(nullptr), BaseName(Name), SurroundingLoop(SurroundingLoop),
+      Instructions(EntryBlockInstructions) {}
 
-ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, Loop *SurroundingLoop,
-                   std::vector<Instruction *> Instructions, int Count)
+ScopStmt::ScopStmt(Scop &parent, BasicBlock &bb, StringRef Name,
+                   Loop *SurroundingLoop,
+                   std::vector<Instruction *> Instructions)
     : Parent(parent), InvalidDomain(nullptr), Domain(nullptr), BB(&bb),
-      Build(nullptr), SurroundingLoop(SurroundingLoop),
-      Instructions(Instructions) {
-  std::string S = "";
-  if (Count != 0)
-    S += std::to_string(Count);
-  BaseName = getIslCompatibleName("Stmt", &bb, parent.getNextStmtIdx(), S,
-                                  UseInstructionNames);
-}
+      Build(nullptr), BaseName(Name), SurroundingLoop(SurroundingLoop),
+      Instructions(Instructions) {}
 
 ScopStmt::ScopStmt(Scop &parent, isl::map SourceRel, isl::map TargetRel,
                    isl::set NewDomain)
@@ -4644,10 +4637,10 @@ static isl::multi_union_pw_aff mapToDime
   return isl::multi_union_pw_aff(isl::union_pw_multi_aff(Result));
 }
 
-void Scop::addScopStmt(BasicBlock *BB, Loop *SurroundingLoop,
-                       std::vector<Instruction *> Instructions, int Count) {
+void Scop::addScopStmt(BasicBlock *BB, StringRef Name, Loop *SurroundingLoop,
+                       std::vector<Instruction *> Instructions) {
   assert(BB && "Unexpected nullptr!");
-  Stmts.emplace_back(*this, *BB, SurroundingLoop, Instructions, Count);
+  Stmts.emplace_back(*this, *BB, Name, SurroundingLoop, Instructions);
   auto *Stmt = &Stmts.back();
   StmtMap[BB].push_back(Stmt);
   for (Instruction *Inst : Instructions) {
@@ -4657,10 +4650,10 @@ void Scop::addScopStmt(BasicBlock *BB, L
   }
 }
 
-void Scop::addScopStmt(Region *R, Loop *SurroundingLoop,
+void Scop::addScopStmt(Region *R, StringRef Name, Loop *SurroundingLoop,
                        std::vector<Instruction *> Instructions) {
   assert(R && "Unexpected nullptr!");
-  Stmts.emplace_back(*this, *R, SurroundingLoop, Instructions);
+  Stmts.emplace_back(*this, *R, Name, SurroundingLoop, Instructions);
   auto *Stmt = &Stmts.back();
 
   for (Instruction *Inst : Instructions) {




More information about the llvm-commits mailing list