[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.
GitOrigin-RevId: e7b9e43c9a7c33c8c10508ce4b40423fbeaa31b3
diff --git a/lib/Support/PollyPasses.def b/lib/Support/PollyPasses.def
index 3083ae2..701421e 100644
--- a/lib/Support/PollyPasses.def
+++ b/lib/Support/PollyPasses.def
@@ -16,6 +16,7 @@
#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/lib/Support/RegisterPasses.cpp b/lib/Support/RegisterPasses.cpp
index 39c9658..4c8d94c 100644
--- a/lib/Support/RegisterPasses.cpp
+++ b/lib/Support/RegisterPasses.cpp
@@ -568,11 +568,11 @@
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 @@
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 @@
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 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
-parseTopLevelPipeline(ModulePassManager &MPM,
+parseTopLevelPipeline(ModulePassManager &MPM, PassInstrumentationCallbacks *PIC,
ArrayRef<PassBuilder::PipelineElement> Pipeline,
bool DebugLogging) {
std::vector<PassBuilder::PipelineElement> FullPipeline;
@@ -678,7 +682,7 @@
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 @@
}
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);