[polly] r270421 - Directly access information through the Scop class [NFC]

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 05:38:06 PDT 2016


Author: jdoerfert
Date: Mon May 23 07:38:05 2016
New Revision: 270421

URL: http://llvm.org/viewvc/llvm-project?rev=270421&view=rev
Log:
Directly access information through the Scop class [NFC]

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/include/polly/Support/SCEVAffinator.h
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/lib/CodeGen/IslAst.cpp
    polly/trunk/lib/Exchange/JSONExporter.cpp
    polly/trunk/lib/Support/SCEVAffinator.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon May 23 07:38:05 2016
@@ -1870,6 +1870,9 @@ public:
   inline const Region &getRegion() const { return R; }
   inline Region &getRegion() { return R; }
 
+  /// @brief Return the function this SCoP is in.
+  Function &getFunction() const { return *R.getEntry()->getParent(); }
+
   /// @brief Get the maximum depth of the loop.
   ///
   /// @return The maximum depth of the loop.

Modified: polly/trunk/include/polly/Support/SCEVAffinator.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/SCEVAffinator.h?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/SCEVAffinator.h (original)
+++ polly/trunk/include/polly/Support/SCEVAffinator.h Mon May 23 07:38:05 2016
@@ -83,7 +83,6 @@ private:
   Scop *S;
   isl_ctx *Ctx;
   unsigned NumIterators;
-  const llvm::Region &R;
   llvm::ScalarEvolution &SE;
   llvm::LoopInfo &LI;
   llvm::BasicBlock *BB;

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon May 23 07:38:05 2016
@@ -1876,21 +1876,20 @@ __isl_give isl_set *Scop::addNonEmptyDom
 
 void Scop::addUserAssumptions(AssumptionCache &AC, DominatorTree &DT,
                               LoopInfo &LI) {
-  auto *R = &getRegion();
-  auto &F = *R->getEntry()->getParent();
+  auto &F = getFunction();
   for (auto &Assumption : AC.assumptions()) {
     auto *CI = dyn_cast_or_null<CallInst>(Assumption);
     if (!CI || CI->getNumArgOperands() != 1)
       continue;
 
-    bool InR = R->contains(CI);
-    if (!InR && !DT.dominates(CI->getParent(), R->getEntry()))
+    bool InR = R.contains(CI);
+    if (!InR && !DT.dominates(CI->getParent(), R.getEntry()))
       continue;
 
     auto *L = LI.getLoopFor(CI->getParent());
     auto *Val = CI->getArgOperand(0);
     ParameterSetTy DetectedParams;
-    if (!isAffineConstraint(Val, R, L, *SE, DetectedParams)) {
+    if (!isAffineConstraint(Val, &R, L, *SE, DetectedParams)) {
       emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F,
                                      CI->getDebugLoc(),
                                      "Non-affine user assumption ignored.");
@@ -2971,7 +2970,7 @@ bool Scop::buildAliasGroups(AliasAnalysi
     isl_set_free(AGDomain);
   }
 
-  auto &F = *getRegion().getEntry()->getParent();
+  auto &F = getFunction();
   MapVector<const Value *, SmallPtrSet<MemoryAccess *, 8>> ReadOnlyPairs;
   SmallPtrSet<const Value *, 4> NonReadOnlyBaseValues;
   for (AliasGroupTy &AG : AliasGroups) {
@@ -3540,7 +3539,7 @@ Scop::getOrCreateScopArrayInfo(Value *Ba
                                ScopArrayInfo::MemoryKind Kind) {
   auto &SAI = ScopArrayInfoMap[std::make_pair(BasePtr, Kind)];
   if (!SAI) {
-    auto &DL = getRegion().getEntry()->getModule()->getDataLayout();
+    auto &DL = getFunction().getParent()->getDataLayout();
     SAI.reset(new ScopArrayInfo(BasePtr, ElementType, getIslCtx(), Sizes, Kind,
                                 DL, this));
   } else {
@@ -3694,7 +3693,7 @@ bool Scop::trackAssumption(AssumptionKin
     }
   }
 
-  auto &F = *getRegion().getEntry()->getParent();
+  auto &F = getFunction();
   auto Suffix = Sign == AS_ASSUMPTION ? " assumption:\t" : " restriction:\t";
   std::string Msg = toString(Kind) + Suffix + stringFromIslObj(Set);
   emitOptimizationRemarkAnalysis(F.getContext(), DEBUG_TYPE, F, Loc, Msg);
@@ -3848,8 +3847,7 @@ void Scop::printArrayInfo(raw_ostream &O
 }
 
 void Scop::print(raw_ostream &OS) const {
-  OS.indent(4) << "Function: " << getRegion().getEntry()->getParent()->getName()
-               << "\n";
+  OS.indent(4) << "Function: " << getFunction().getName() << "\n";
   OS.indent(4) << "Region: " << getNameStr() << "\n";
   OS.indent(4) << "Max Loop Depth:  " << getMaxLoopDepth() << "\n";
   OS.indent(4) << "Invariant Accesses: {\n";

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Mon May 23 07:38:05 2016
@@ -79,8 +79,7 @@ Value *BlockGenerator::trySynthesizeNewV
   VTV.insert(GlobalMap.begin(), GlobalMap.end());
 
   Scop &S = *Stmt.getParent();
-  const DataLayout &DL =
-      S.getRegion().getEntry()->getParent()->getParent()->getDataLayout();
+  const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
   auto IP = Builder.GetInsertPoint();
 
   assert(IP != Builder.GetInsertBlock()->end() &&

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon May 23 07:38:05 2016
@@ -133,7 +133,7 @@ public:
     LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
     DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
     SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
-    DL = &S.getRegion().getEntry()->getParent()->getParent()->getDataLayout();
+    DL = &S.getFunction().getParent()->getDataLayout();
     RI = &getAnalysis<RegionInfoPass>().getRegionInfo();
     Region *R = &S.getRegion();
     assert(!R->isTopLevelRegion() && "Top level regions are not supported");

Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Mon May 23 07:38:05 2016
@@ -564,10 +564,9 @@ isl_ast_build *IslAstInfo::getBuild(__is
 void IslAstInfo::printScop(raw_ostream &OS, Scop &S) const {
   isl_ast_print_options *Options;
   isl_ast_node *RootNode = getAst();
-  Function *F = S.getRegion().getEntry()->getParent();
+  Function &F = S.getFunction();
 
-  OS << ":: isl ast :: " << F->getName() << " :: " << S.getRegion().getNameStr()
-     << "\n";
+  OS << ":: isl ast :: " << F.getName() << " :: " << S.getNameStr() << "\n";
 
   if (!RootNode) {
     OS << ":: isl ast generation and code generation was skipped!\n\n";

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Mon May 23 07:38:05 2016
@@ -91,7 +91,7 @@ struct JSONImporter : public ScopPass {
 
 char JSONExporter::ID = 0;
 std::string JSONExporter::getFileName(Scop &S) const {
-  std::string FunctionName = S.getRegion().getEntry()->getParent()->getName();
+  std::string FunctionName = S.getFunction().getName();
   std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
   return FileName;
 }
@@ -109,7 +109,7 @@ Json::Value JSONExporter::getJSON(Scop &
     Location = FileName + ":" + std::to_string(LineBegin) + "-" +
                std::to_string(LineEnd);
 
-  root["name"] = S.getRegion().getNameStr();
+  root["name"] = S.getNameStr();
   root["context"] = S.getContextStr();
   if (LineBegin != (unsigned)-1)
     root["location"] = Location;
@@ -139,8 +139,6 @@ Json::Value JSONExporter::getJSON(Scop &
 }
 
 bool JSONExporter::runOnScop(Scop &S) {
-  Region &R = S.getRegion();
-
   std::string FileName = ImportDir + "/" + getFileName(S);
 
   Json::Value jscop = getJSON(S);
@@ -151,8 +149,8 @@ bool JSONExporter::runOnScop(Scop &S) {
   std::error_code EC;
   tool_output_file F(FileName, EC, llvm::sys::fs::F_Text);
 
-  std::string FunctionName = R.getEntry()->getParent()->getName();
-  errs() << "Writing JScop '" << R.getNameStr() << "' in function '"
+  std::string FunctionName = S.getFunction().getName();
+  errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
          << FunctionName << "' to '" << FileName << "'.\n";
 
   if (!EC) {
@@ -180,7 +178,7 @@ Pass *polly::createJSONExporterPass() {
 
 char JSONImporter::ID = 0;
 std::string JSONImporter::getFileName(Scop &S) const {
-  std::string FunctionName = S.getRegion().getEntry()->getParent()->getName();
+  std::string FunctionName = S.getFunction().getName();
   std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";
 
   if (ImportPostfix != "")
@@ -200,16 +198,14 @@ void JSONImporter::printScop(raw_ostream
 typedef Dependences::StatementToIslMapTy StatementToIslMapTy;
 
 bool JSONImporter::runOnScop(Scop &S) {
-  Region &R = S.getRegion();
   const Dependences &D =
       getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
-  const DataLayout &DL =
-      S.getRegion().getEntry()->getParent()->getParent()->getDataLayout();
+  const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
 
   std::string FileName = ImportDir + "/" + getFileName(S);
 
-  std::string FunctionName = R.getEntry()->getParent()->getName();
-  errs() << "Reading JScop '" << R.getNameStr() << "' in function '"
+  std::string FunctionName = S.getFunction().getName();
+  errs() << "Reading JScop '" << S.getNameStr() << "' in function '"
          << FunctionName << "' from '" << FileName << "'.\n";
   ErrorOr<std::unique_ptr<MemoryBuffer>> result =
       MemoryBuffer::getFile(FileName);

Modified: polly/trunk/lib/Support/SCEVAffinator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVAffinator.cpp?rev=270421&r1=270420&r2=270421&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVAffinator.cpp (original)
+++ polly/trunk/lib/Support/SCEVAffinator.cpp Mon May 23 07:38:05 2016
@@ -127,8 +127,8 @@ static __isl_give isl_pw_aff *getWidthEx
 }
 
 SCEVAffinator::SCEVAffinator(Scop *S, LoopInfo &LI)
-    : S(S), Ctx(S->getIslCtx()), R(S->getRegion()), SE(*S->getSE()), LI(LI),
-      TD(R.getEntry()->getParent()->getParent()->getDataLayout()) {}
+    : S(S), Ctx(S->getIslCtx()), SE(*S->getSE()), LI(LI),
+      TD(S->getFunction().getParent()->getDataLayout()) {}
 
 SCEVAffinator::~SCEVAffinator() {
   for (auto &CachedPair : CachedExpressions)
@@ -170,7 +170,7 @@ __isl_give PWACtx SCEVAffinator::getPwAf
     NumIterators = 0;
 
   auto *Scope = LI.getLoopFor(BB);
-  S->addParams(getParamsInAffineExpr(&R, Scope, Expr, SE));
+  S->addParams(getParamsInAffineExpr(&S->getRegion(), Scope, Expr, SE));
 
   return visit(Expr);
 }




More information about the llvm-commits mailing list