[NewPM] Make InlinerPass (aka 'inline') a parameterized pass
In default pipelines the ModuleInlinerWrapperPass is adding the InlinerPass to the pipeline twice, once due to MandatoryFirst (passing true in the ctor) and then a second time with false as argument. To make it possible to bisect and reduce opt test cases for this part of the pipeline we need to be able to choose between the two different variants of the InlinerPass when running opt. This patch is changing 'inline' to a CGSCC_PASS_WITH_PARAMS in the PassRegistry, making it possible run opt with both -passes=cgscc(inline) and -passes=cgscc(inline<only-mandatory>). Reviewed By: aeubanks, mtrofin Differential Revision: https://reviews.llvm.org/D109877
This commit is contained in:
parent
eb3af1e773
commit
c8cb7f611f
|
@ -103,6 +103,9 @@ public:
|
||||||
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
|
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
|
||||||
LazyCallGraph &CG, CGSCCUpdateResult &UR);
|
LazyCallGraph &CG, CGSCCUpdateResult &UR);
|
||||||
|
|
||||||
|
void printPipeline(raw_ostream &OS,
|
||||||
|
function_ref<StringRef(StringRef)> MapClassName2PassName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InlineAdvisor &getAdvisor(const ModuleAnalysisManagerCGSCCProxy::Result &MAM,
|
InlineAdvisor &getAdvisor(const ModuleAnalysisManagerCGSCCProxy::Result &MAM,
|
||||||
FunctionAnalysisManager &FAM, Module &M);
|
FunctionAnalysisManager &FAM, Module &M);
|
||||||
|
|
|
@ -386,6 +386,8 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
|
||||||
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
||||||
#define CGSCC_PASS(NAME, CREATE_PASS) \
|
#define CGSCC_PASS(NAME, CREATE_PASS) \
|
||||||
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
|
||||||
|
PIC->addClassToPassName(CLASS, NAME);
|
||||||
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
|
||||||
#include "PassRegistry.def"
|
#include "PassRegistry.def"
|
||||||
|
@ -558,6 +560,10 @@ Expected<bool> parseSinglePassOption(StringRef Params, StringRef OptionName,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expected<bool> parseInlinerPassOptions(StringRef Params) {
|
||||||
|
return parseSinglePassOption(Params, "only-mandatory", "InlinerPass");
|
||||||
|
}
|
||||||
|
|
||||||
Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
|
Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
|
||||||
return parseSinglePassOption(Params, "memssa", "EarlyCSE");
|
return parseSinglePassOption(Params, "memssa", "EarlyCSE");
|
||||||
}
|
}
|
||||||
|
@ -863,6 +869,9 @@ static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
|
||||||
#define CGSCC_PASS(NAME, CREATE_PASS) \
|
#define CGSCC_PASS(NAME, CREATE_PASS) \
|
||||||
if (Name == NAME) \
|
if (Name == NAME) \
|
||||||
return true;
|
return true;
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
|
||||||
|
if (checkParametrizedPassName(Name, NAME)) \
|
||||||
|
return true;
|
||||||
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
|
if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
|
||||||
return true;
|
return true;
|
||||||
|
@ -1107,6 +1116,15 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
|
||||||
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
|
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
|
||||||
return Error::success(); \
|
return Error::success(); \
|
||||||
}
|
}
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
|
||||||
|
if (checkParametrizedPassName(Name, NAME)) { \
|
||||||
|
auto Params = parsePassParameters(PARSER, Name, NAME); \
|
||||||
|
if (!Params) \
|
||||||
|
return Params.takeError(); \
|
||||||
|
MPM.addPass( \
|
||||||
|
createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
|
||||||
|
return Error::success(); \
|
||||||
|
}
|
||||||
#define FUNCTION_PASS(NAME, CREATE_PASS) \
|
#define FUNCTION_PASS(NAME, CREATE_PASS) \
|
||||||
if (Name == NAME) { \
|
if (Name == NAME) { \
|
||||||
MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
|
MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
|
||||||
|
@ -1201,6 +1219,14 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
|
||||||
CGPM.addPass(CREATE_PASS); \
|
CGPM.addPass(CREATE_PASS); \
|
||||||
return Error::success(); \
|
return Error::success(); \
|
||||||
}
|
}
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
|
||||||
|
if (checkParametrizedPassName(Name, NAME)) { \
|
||||||
|
auto Params = parsePassParameters(PARSER, Name, NAME); \
|
||||||
|
if (!Params) \
|
||||||
|
return Params.takeError(); \
|
||||||
|
CGPM.addPass(CREATE_PASS(Params.get())); \
|
||||||
|
return Error::success(); \
|
||||||
|
}
|
||||||
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
|
||||||
if (Name == "require<" NAME ">") { \
|
if (Name == "require<" NAME ">") { \
|
||||||
CGPM.addPass(RequireAnalysisPass< \
|
CGPM.addPass(RequireAnalysisPass< \
|
||||||
|
@ -1683,6 +1709,11 @@ void PassBuilder::printPassNames(raw_ostream &OS) {
|
||||||
#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
|
#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
|
||||||
#include "PassRegistry.def"
|
#include "PassRegistry.def"
|
||||||
|
|
||||||
|
OS << "CGSCC passes with params:\n";
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
|
||||||
|
printPassName(NAME, PARAMS, OS);
|
||||||
|
#include "PassRegistry.def"
|
||||||
|
|
||||||
OS << "CGSCC analyses:\n";
|
OS << "CGSCC analyses:\n";
|
||||||
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
|
#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
|
||||||
#include "PassRegistry.def"
|
#include "PassRegistry.def"
|
||||||
|
|
|
@ -162,12 +162,23 @@ CGSCC_PASS("argpromotion", ArgumentPromotionPass())
|
||||||
CGSCC_PASS("invalidate<all>", InvalidateAllAnalysesPass())
|
CGSCC_PASS("invalidate<all>", InvalidateAllAnalysesPass())
|
||||||
CGSCC_PASS("function-attrs", PostOrderFunctionAttrsPass())
|
CGSCC_PASS("function-attrs", PostOrderFunctionAttrsPass())
|
||||||
CGSCC_PASS("attributor-cgscc", AttributorCGSCCPass())
|
CGSCC_PASS("attributor-cgscc", AttributorCGSCCPass())
|
||||||
CGSCC_PASS("inline", InlinerPass())
|
|
||||||
CGSCC_PASS("openmp-opt-cgscc", OpenMPOptCGSCCPass())
|
CGSCC_PASS("openmp-opt-cgscc", OpenMPOptCGSCCPass())
|
||||||
CGSCC_PASS("coro-split", CoroSplitPass())
|
CGSCC_PASS("coro-split", CoroSplitPass())
|
||||||
CGSCC_PASS("no-op-cgscc", NoOpCGSCCPass())
|
CGSCC_PASS("no-op-cgscc", NoOpCGSCCPass())
|
||||||
#undef CGSCC_PASS
|
#undef CGSCC_PASS
|
||||||
|
|
||||||
|
#ifndef CGSCC_PASS_WITH_PARAMS
|
||||||
|
#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS)
|
||||||
|
#endif
|
||||||
|
CGSCC_PASS_WITH_PARAMS("inline",
|
||||||
|
"InlinerPass",
|
||||||
|
[](bool OnlyMandatory) {
|
||||||
|
return InlinerPass(OnlyMandatory);
|
||||||
|
},
|
||||||
|
parseInlinerPassOptions,
|
||||||
|
"only-mandatory")
|
||||||
|
#undef CGSCC_PASS_WITH_PARAMS
|
||||||
|
|
||||||
#ifndef FUNCTION_ANALYSIS
|
#ifndef FUNCTION_ANALYSIS
|
||||||
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
|
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1053,3 +1053,11 @@ PreservedAnalyses ModuleInlinerWrapperPass::run(Module &M,
|
||||||
// The ModulePassManager has already taken care of invalidating analyses.
|
// The ModulePassManager has already taken care of invalidating analyses.
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InlinerPass::printPipeline(
|
||||||
|
raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
|
||||||
|
static_cast<PassInfoMixin<InlinerPass> *>(this)->printPipeline(
|
||||||
|
OS, MapClassName2PassName);
|
||||||
|
if (OnlyMandatory)
|
||||||
|
OS << "<only-mandatory>";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue