[polly] 08bab4b - [Polly] Make NewPM's IslAstAnalysis more similar to the legacy IslAstInfoWrapperPass.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 21:59:08 PST 2021
Author: Michael Kruse
Date: 2021-02-09T23:56:21-06:00
New Revision: 08bab4b0302106803d7cd7c4504dd63c296c40a0
URL: https://github.com/llvm/llvm-project/commit/08bab4b0302106803d7cd7c4504dd63c296c40a0
DIFF: https://github.com/llvm/llvm-project/commit/08bab4b0302106803d7cd7c4504dd63c296c40a0.diff
LOG: [Polly] Make NewPM's IslAstAnalysis more similar to the legacy IslAstInfoWrapperPass.
In particular, print the ast with -debug-only=polly-ast, print a
per-scop header with print<polly-ast> and force-add the analysis with
-polly-code-generation=ast.
Added:
Modified:
polly/lib/CodeGen/IslAst.cpp
polly/lib/Support/RegisterPasses.cpp
Removed:
################################################################################
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp
index 94367bd331b0..d846df18d92b 100644
--- a/polly/lib/CodeGen/IslAst.cpp
+++ b/polly/lib/CodeGen/IslAst.cpp
@@ -663,10 +663,40 @@ isl_ast_build *IslAstInfo::getBuild(__isl_keep isl_ast_node *Node) {
return Payload ? Payload->Build : nullptr;
}
+static std::unique_ptr<IslAstInfo> runIslAst(
+ Scop &Scop,
+ function_ref<const Dependences &(Dependences::AnalysisLevel)> GetDeps) {
+ // Skip SCoPs in case they're already handled by PPCGCodeGeneration.
+ if (Scop.isToBeSkipped())
+ return {};
+
+ ScopsProcessed++;
+
+ const Dependences &D = GetDeps(Dependences::AL_Statement);
+
+ if (D.getSharedIslCtx() != Scop.getSharedIslCtx()) {
+ LLVM_DEBUG(
+ dbgs() << "Got dependence analysis for
diff erent SCoP/isl_ctx\n");
+ return {};
+ }
+
+ std::unique_ptr<IslAstInfo> Ast = std::make_unique<IslAstInfo>(Scop, D);
+
+ LLVM_DEBUG({
+ if (Ast)
+ Ast->print(dbgs());
+ });
+
+ return Ast;
+}
+
IslAstInfo IslAstAnalysis::run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR) {
- return {S, SAM.getResult<DependenceAnalysis>(S, SAR).getDependences(
- Dependences::AL_Statement)};
+ auto GetDeps = [&](Dependences::AnalysisLevel Lvl) -> const Dependences & {
+ return SAM.getResult<DependenceAnalysis>(S, SAR).getDependences(Lvl);
+ };
+
+ return std::move(*runIslAst(S, GetDeps).release());
}
static __isl_give isl_printer *cbPrintUser(__isl_take isl_printer *P,
@@ -785,25 +815,12 @@ PreservedAnalyses IslAstPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
void IslAstInfoWrapperPass::releaseMemory() { Ast.reset(); }
bool IslAstInfoWrapperPass::runOnScop(Scop &Scop) {
- // Skip SCoPs in case they're already handled by PPCGCodeGeneration.
- if (Scop.isToBeSkipped())
- return false;
-
- ScopsProcessed++;
-
- const Dependences &D =
- getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
-
- if (D.getSharedIslCtx() != Scop.getSharedIslCtx()) {
- LLVM_DEBUG(
- dbgs() << "Got dependence analysis for
diff erent SCoP/isl_ctx\n");
- Ast.reset();
- return false;
- }
+ auto GetDeps = [this](Dependences::AnalysisLevel Lvl) -> const Dependences & {
+ return getAnalysis<DependenceInfo>().getDependences(Lvl);
+ };
- Ast.reset(new IslAstInfo(Scop, D));
+ Ast = runIslAst(Scop, GetDeps);
- LLVM_DEBUG(printScop(dbgs(), Scop));
return false;
}
@@ -817,6 +834,8 @@ void IslAstInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
}
void IslAstInfoWrapperPass::printScop(raw_ostream &OS, Scop &S) const {
+ OS << "Printing analysis 'Polly - Generate an AST of the SCoP (isl)'"
+ << S.getName() << "' in function '" << S.getFunction().getName() << "':\n";
if (Ast)
Ast->print(OS);
}
diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp
index a16bab806dcf..1c72b634dfd1 100644
--- a/polly/lib/Support/RegisterPasses.cpp
+++ b/polly/lib/Support/RegisterPasses.cpp
@@ -497,11 +497,15 @@ static void buildDefaultPollyPipeline(FunctionPassManager &PM,
if (Target == TARGET_CPU || Target == TARGET_HYBRID) {
switch (CodeGeneration) {
+ case CODEGEN_AST:
+ SPM.addPass(
+ RequireAnalysisPass<IslAstAnalysis, Scop, ScopAnalysisManager,
+ ScopStandardAnalysisResults &, SPMUpdater &>());
+ break;
case CODEGEN_FULL:
SPM.addPass(polly::CodeGenerationPass());
break;
- case CODEGEN_AST:
- default: // Does it actually make sense to distinguish IslAst codegen?
+ default:
break;
}
}
More information about the llvm-commits
mailing list