[polly] r366266 - [NFC][ScopBuilder] Move addUserContext to ScopBuilder

Dominik Adamski via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 14:29:06 PDT 2019


Author: domada
Date: Tue Jul 16 14:29:06 2019
New Revision: 366266

URL: http://llvm.org/viewvc/llvm-project?rev=366266&view=rev
Log:
[NFC][ScopBuilder] Move addUserContext to ScopBuilder

Scope of changes:
1) Moved addUserContext to ScopBuilder.
2) Moved command line option UserContextStr to ScopBuilder.

Differential Revision: https://reviews.llvm.org/D63740

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=366266&r1=366265&r2=366266&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Tue Jul 16 14:29:06 2019
@@ -376,6 +376,9 @@ class ScopBuilder {
                       BasicBlock *IncomingBlock, Value *IncomingValue,
                       bool IsExitBlock);
 
+  /// Add user provided parameter constraints to context (command line).
+  void addUserContext();
+
   /// Add all recorded assumptions to the assumed context.
   void addRecordedAssumptions();
 

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=366266&r1=366265&r2=366266&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Jul 16 14:29:06 2019
@@ -2044,9 +2044,6 @@ private:
   void addUserAssumptions(AssumptionCache &AC, DominatorTree &DT, LoopInfo &LI,
                           DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
 
-  /// Add user provided parameter constraints to context (command line).
-  void addUserContext();
-
   /// Add the bounds of the parameters to the context.
   void addParameterBounds();
 

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=366266&r1=366265&r2=366266&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Tue Jul 16 14:29:06 2019
@@ -114,6 +114,11 @@ static cl::opt<bool> UnprofitableScalarA
     cl::desc("Count statements with scalar accesses as not optimizable"),
     cl::Hidden, cl::init(false), cl::cat(PollyCategory));
 
+static cl::opt<std::string> UserContextStr(
+    "polly-context", cl::value_desc("isl parameter set"),
+    cl::desc("Provide additional constraints on the context parameters"),
+    cl::init(""), cl::cat(PollyCategory));
+
 static cl::opt<bool> DetectFortranArrays(
     "polly-detect-fortran-arrays",
     cl::desc("Detect Fortran arrays and use this for code generation"),
@@ -1454,6 +1459,45 @@ bool ScopBuilder::hasNonHoistableBasePtr
   return false;
 }
 
+void ScopBuilder::addUserContext() {
+  if (UserContextStr.empty())
+    return;
+
+  isl::set UserContext = isl::set(scop->getIslCtx(), UserContextStr.c_str());
+  isl::space Space = scop->getParamSpace();
+  if (Space.dim(isl::dim::param) != UserContext.dim(isl::dim::param)) {
+    std::string SpaceStr = Space.to_str();
+    errs() << "Error: the context provided in -polly-context has not the same "
+           << "number of dimensions than the computed context. Due to this "
+           << "mismatch, the -polly-context option is ignored. Please provide "
+           << "the context in the parameter space: " << SpaceStr << ".\n";
+    return;
+  }
+
+  for (unsigned i = 0; i < Space.dim(isl::dim::param); i++) {
+    std::string NameContext =
+        scop->getContext().get_dim_name(isl::dim::param, i);
+    std::string NameUserContext = UserContext.get_dim_name(isl::dim::param, i);
+
+    if (NameContext != NameUserContext) {
+      std::string SpaceStr = Space.to_str();
+      errs() << "Error: the name of dimension " << i
+             << " provided in -polly-context "
+             << "is '" << NameUserContext << "', but the name in the computed "
+             << "context is '" << NameContext
+             << "'. Due to this name mismatch, "
+             << "the -polly-context option is ignored. Please provide "
+             << "the context in the parameter space: " << SpaceStr << ".\n";
+      return;
+    }
+
+    UserContext = UserContext.set_dim_id(isl::dim::param, i,
+                                         Space.get_dim_id(isl::dim::param, i));
+  }
+  isl::set newContext = scop->getContext().intersect(UserContext);
+  scop->setContext(newContext);
+}
+
 isl::set ScopBuilder::getNonHoistableCtx(MemoryAccess *Access,
                                          isl::union_map Writes) {
   // TODO: Loads that are not loop carried, hence are in a statement with
@@ -2326,7 +2370,7 @@ void ScopBuilder::buildScop(Region &R, A
   scop->finalizeAccesses();
 
   scop->realignParams();
-  scop->addUserContext();
+  addUserContext();
 
   // After the context was fully constructed, thus all our knowledge about
   // the parameters is in there, we add all recorded assumptions to the

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=366266&r1=366265&r2=366266&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Jul 16 14:29:06 2019
@@ -122,11 +122,6 @@ static cl::opt<bool> PollyRemarksMinimal
     cl::desc("Do not emit remarks about assumptions that are known"),
     cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::cat(PollyCategory));
 
-static cl::opt<std::string> UserContextStr(
-    "polly-context", cl::value_desc("isl parameter set"),
-    cl::desc("Provide additional constraints on the context parameters"),
-    cl::init(""), cl::cat(PollyCategory));
-
 static cl::opt<bool>
     IslOnErrorAbort("polly-on-isl-error-abort",
                     cl::desc("Abort if an isl error is encountered"),
@@ -2017,44 +2012,6 @@ void Scop::addUserAssumptions(
   }
 }
 
-void Scop::addUserContext() {
-  if (UserContextStr.empty())
-    return;
-
-  isl::set UserContext = isl::set(getIslCtx(), UserContextStr.c_str());
-  isl::space Space = getParamSpace();
-  if (Space.dim(isl::dim::param) != UserContext.dim(isl::dim::param)) {
-    std::string SpaceStr = Space.to_str();
-    errs() << "Error: the context provided in -polly-context has not the same "
-           << "number of dimensions than the computed context. Due to this "
-           << "mismatch, the -polly-context option is ignored. Please provide "
-           << "the context in the parameter space: " << SpaceStr << ".\n";
-    return;
-  }
-
-  for (unsigned i = 0; i < Space.dim(isl::dim::param); i++) {
-    std::string NameContext = Context.get_dim_name(isl::dim::param, i);
-    std::string NameUserContext = UserContext.get_dim_name(isl::dim::param, i);
-
-    if (NameContext != NameUserContext) {
-      std::string SpaceStr = Space.to_str();
-      errs() << "Error: the name of dimension " << i
-             << " provided in -polly-context "
-             << "is '" << NameUserContext << "', but the name in the computed "
-             << "context is '" << NameContext
-             << "'. Due to this name mismatch, "
-             << "the -polly-context option is ignored. Please provide "
-             << "the context in the parameter space: " << SpaceStr << ".\n";
-      return;
-    }
-
-    UserContext = UserContext.set_dim_id(isl::dim::param, i,
-                                         Space.get_dim_id(isl::dim::param, i));
-  }
-
-  Context = Context.intersect(UserContext);
-}
-
 void Scop::buildContext() {
   isl::space Space = isl::space::params_alloc(getIslCtx(), 0);
   Context = isl::set::universe(Space);




More information about the llvm-commits mailing list