[polly] e7b9e43 - [Polly] Register pass-instrumentation for NewPM's Scop level.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 21:58:59 PST 2021
Author: Michael Kruse
Date: 2021-02-09T23:56:20-06:00
New Revision: e7b9e43c9a7c33c8c10508ce4b40423fbeaa31b3
URL: https://github.com/llvm/llvm-project/commit/e7b9e43c9a7c33c8c10508ce4b40423fbeaa31b3
DIFF: https://github.com/llvm/llvm-project/commit/e7b9e43c9a7c33c8c10508ce4b40423fbeaa31b3.diff
LOG: [Polly] Register pass-instrumentation for NewPM's Scop level.
The pass-instrumentation pass is implicitly execute by the NewPM
whenever a new analysis runs. Not registering it will cause the crash
whenever a scop pass requests an analysis.
For instance this is the case for the IstAstAnalysis requesting the
DependenceAnalsis result.
Added:
Modified:
polly/lib/Support/PollyPasses.def
polly/lib/Support/RegisterPasses.cpp
Removed:
################################################################################
diff --git a/polly/lib/Support/PollyPasses.def b/polly/lib/Support/PollyPasses.def
index 3083ae2b5a20..701421e3e6b4 100644
--- a/polly/lib/Support/PollyPasses.def
+++ b/polly/lib/Support/PollyPasses.def
@@ -16,6 +16,7 @@ FUNCTION_PASS("print<polly-function-scops>", ScopInfoPrinterPass(errs()))
#ifndef SCOP_ANALYSIS
#define SCOP_ANALYSIS(NAME, CREATE_PASS)
#endif
+SCOP_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
SCOP_ANALYSIS("polly-ast", IslAstAnalysis())
SCOP_ANALYSIS("polly-dependences", DependenceAnalysis())
#undef SCOP_ANALYSIS
diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp
index 39c965831993..4c8d94c13fea 100644
--- a/polly/lib/Support/RegisterPasses.cpp
+++ b/polly/lib/Support/RegisterPasses.cpp
@@ -568,11 +568,11 @@ static llvm::RegisterStandardPasses RegisterPollyOptimizerScalarLate(
registerPollyScalarOptimizerLatePasses);
static OwningScopAnalysisManagerFunctionProxy
-createScopAnalyses(FunctionAnalysisManager &FAM) {
+createScopAnalyses(FunctionAnalysisManager &FAM,
+ PassInstrumentationCallbacks *PIC) {
OwningScopAnalysisManagerFunctionProxy Proxy;
#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
- Proxy.getManager().registerPass([] { return CREATE_PASS; });
-
+ Proxy.getManager().registerPass([PIC] { return CREATE_PASS; });
#include "PollyPasses.def"
Proxy.getManager().registerPass(
@@ -580,13 +580,15 @@ createScopAnalyses(FunctionAnalysisManager &FAM) {
return Proxy;
}
-static void registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
+static void registerFunctionAnalyses(FunctionAnalysisManager &FAM,
+ PassInstrumentationCallbacks *PIC) {
+
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
FAM.registerPass([] { return CREATE_PASS; });
#include "PollyPasses.def"
- FAM.registerPass([&FAM] { return createScopAnalyses(FAM); });
+ FAM.registerPass([&FAM, PIC] { return createScopAnalyses(FAM, PIC); });
}
static bool
@@ -612,7 +614,8 @@ parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
return false;
}
-static bool parseScopPass(StringRef Name, ScopPassManager &SPM) {
+static bool parseScopPass(StringRef Name, ScopPassManager &SPM,
+ PassInstrumentationCallbacks *PIC) {
#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
if (parseAnalysisUtilityPasses< \
std::remove_reference<decltype(CREATE_PASS)>::type>(NAME, Name, \
@@ -631,13 +634,14 @@ static bool parseScopPass(StringRef Name, ScopPassManager &SPM) {
}
static bool parseScopPipeline(StringRef Name, FunctionPassManager &FPM,
+ PassInstrumentationCallbacks *PIC,
ArrayRef<PassBuilder::PipelineElement> Pipeline) {
if (Name != "scop")
return false;
if (!Pipeline.empty()) {
ScopPassManager SPM;
for (const auto &E : Pipeline)
- if (!parseScopPass(E.Name, SPM))
+ if (!parseScopPass(E.Name, SPM, PIC))
return false;
FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
}
@@ -661,7 +665,7 @@ static bool isScopPassName(StringRef Name) {
}
static bool
-parseTopLevelPipeline(ModulePassManager &MPM,
+parseTopLevelPipeline(ModulePassManager &MPM, PassInstrumentationCallbacks *PIC,
ArrayRef<PassBuilder::PipelineElement> Pipeline,
bool DebugLogging) {
std::vector<PassBuilder::PipelineElement> FullPipeline;
@@ -678,7 +682,7 @@ parseTopLevelPipeline(ModulePassManager &MPM,
auto &InnerPipeline = Element.InnerPipeline;
if (!InnerPipeline.empty()) // Scop passes don't have inner pipelines
return false;
- if (!parseScopPass(Name, SPM))
+ if (!parseScopPass(Name, SPM, PIC))
return false;
}
@@ -689,10 +693,22 @@ parseTopLevelPipeline(ModulePassManager &MPM,
}
void registerPollyPasses(PassBuilder &PB) {
- PB.registerAnalysisRegistrationCallback(registerFunctionAnalyses);
+ PassInstrumentationCallbacks *PIC = PB.getPassInstrumentationCallbacks();
+ PB.registerAnalysisRegistrationCallback([PIC](FunctionAnalysisManager &FAM) {
+ registerFunctionAnalyses(FAM, PIC);
+ });
PB.registerPipelineParsingCallback(parseFunctionPipeline);
- PB.registerPipelineParsingCallback(parseScopPipeline);
- PB.registerParseTopLevelPipelineCallback(parseTopLevelPipeline);
+ PB.registerPipelineParsingCallback(
+ [PIC](StringRef Name, FunctionPassManager &FPM,
+ ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
+ return parseScopPipeline(Name, FPM, PIC, Pipeline);
+ });
+ PB.registerParseTopLevelPipelineCallback(
+ [PIC](ModulePassManager &MPM,
+ ArrayRef<PassBuilder::PipelineElement> Pipeline,
+ bool DebugLogging) -> bool {
+ return parseTopLevelPipeline(MPM, PIC, Pipeline, DebugLogging);
+ });
if (PassPosition == POSITION_BEFORE_VECTORIZER)
PB.registerVectorizerStartEPCallback(buildDefaultPollyPipeline);
More information about the llvm-commits
mailing list