summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/include/polly/ScopInfo.h3
-rw-r--r--polly/include/polly/Support/SCEVAffinator.h1
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp18
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp3
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp2
-rw-r--r--polly/lib/CodeGen/IslAst.cpp5
-rw-r--r--polly/lib/Exchange/JSONExporter.cpp20
-rw-r--r--polly/lib/Support/SCEVAffinator.cpp6
8 files changed, 26 insertions, 32 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index bb86ec1443b..67d4d4ce26e 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -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.
diff --git a/polly/include/polly/Support/SCEVAffinator.h b/polly/include/polly/Support/SCEVAffinator.h
index 8706f85aedf..c89cdbb7094 100644
--- a/polly/include/polly/Support/SCEVAffinator.h
+++ b/polly/include/polly/Support/SCEVAffinator.h
@@ -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;
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 0db3d833a7b..dc622db9387 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1876,21 +1876,20 @@ __isl_give isl_set *Scop::addNonEmptyDomainConstraints(isl_set *C) const {
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(AliasAnalysis &AA) {
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 *BasePtr, Type *ElementType,
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(AssumptionKind Kind, __isl_keep isl_set *Set,
}
}
- 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 &OS) const {
}
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";
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 79d6d0b8464..569279b85ea 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -79,8 +79,7 @@ Value *BlockGenerator::trySynthesizeNewValue(ScopStmt &Stmt, Value *Old,
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() &&
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index 757e24813cf..729de9bec58 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -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");
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp
index 40b802bece8..4ee169bfd43 100644
--- a/polly/lib/CodeGen/IslAst.cpp
+++ b/polly/lib/CodeGen/IslAst.cpp
@@ -564,10 +564,9 @@ isl_ast_build *IslAstInfo::getBuild(__isl_keep isl_ast_node *Node) {
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";
diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp
index 5047f90d6af..63e7bdda181 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -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 &S) const {
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 &S) const {
}
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() { return new JSONExporter(); }
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 &OS, Scop &S) const {
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);
diff --git a/polly/lib/Support/SCEVAffinator.cpp b/polly/lib/Support/SCEVAffinator.cpp
index 0998584cb21..47a42c7b58e 100644
--- a/polly/lib/Support/SCEVAffinator.cpp
+++ b/polly/lib/Support/SCEVAffinator.cpp
@@ -127,8 +127,8 @@ static __isl_give isl_pw_aff *getWidthExpValOnDomain(unsigned Width,
}
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::getPwAff(const SCEV *Expr, BasicBlock *BB) {
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);
}
OpenPOWER on IntegriCloud