[Attributor][PM] Introduce `-attributor-enable={none,cgscc,module,all}`

The old command line option `-attributor-disable` was too coarse grained
as we want to measure the effects of the module or cgscc pass without
the other as well.

Since `none` is the default there is no real functional change.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D78571
This commit is contained in:
Johannes Doerfert 2020-04-17 21:43:54 -05:00
parent e2b53a4c05
commit c5794f77eb
3 changed files with 26 additions and 11 deletions

View File

@ -2862,6 +2862,14 @@ struct AAValueConstantRange : public IntegerRangeState,
static const char ID;
};
/// Run options, used by the pass manager.
enum AttributorRunOption {
NONE = 0,
MODULE = 1 << 0,
CGSCC = 1 << 1,
ALL = MODULE | CGSCC
};
} // end namespace llvm
#endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H

View File

@ -258,7 +258,7 @@ extern cl::opt<bool> EnableOrderFileInstrumentation;
extern cl::opt<bool> FlattenedProfileUsed;
extern cl::opt<bool> DisableAttributor;
extern cl::opt<AttributorRunOption> AttributorRun;
const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
/*SpeedLevel*/ 0,
@ -768,7 +768,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
true /* SamplePGO */));
}
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::MODULE)
MPM.addPass(AttributorPass());
// Interprocedural constant propagation now that basic cleanup has occurred
@ -852,7 +852,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
IP.HotCallSiteThreshold = 0;
MainCGPipeline.addPass(InlinerPass(IP));
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::CGSCC)
MainCGPipeline.addPass(AttributorCGSCCPass());
if (PTO.Coroutines)

View File

@ -153,10 +153,17 @@ static cl::opt<bool>
EnableMatrix("enable-matrix", cl::init(false), cl::Hidden,
cl::desc("Enable lowering of the matrix intrinsics"));
cl::opt<bool> DisableAttributor(
"attributor-disable", cl::Hidden,
cl::desc("Disable the attributor inter-procedural deduction pass."),
cl::init(true));
cl::opt<AttributorRunOption> AttributorRun(
"attributor-enable", cl::Hidden, cl::init(AttributorRunOption::NONE),
cl::desc("Enable the attributor inter-procedural deduction pass."),
cl::values(clEnumValN(AttributorRunOption::ALL, "all",
"enable all attributor runs"),
clEnumValN(AttributorRunOption::MODULE, "module",
"enable module-wide attributor runs"),
clEnumValN(AttributorRunOption::CGSCC, "cgscc",
"enable call graph SCC attributor runs"),
clEnumValN(AttributorRunOption::NONE, "none",
"disable attributor runs")));
PassManagerBuilder::PassManagerBuilder() {
OptLevel = 2;
@ -552,7 +559,7 @@ void PassManagerBuilder::populateModulePassManager(
MPM.add(createInferFunctionAttrsLegacyPass());
// Infer attributes on declarations, call sites, arguments, etc.
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::MODULE)
MPM.add(createAttributorLegacyPass());
addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
@ -601,7 +608,7 @@ void PassManagerBuilder::populateModulePassManager(
}
// Infer attributes on declarations, call sites, arguments, etc. for an SCC.
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::CGSCC)
MPM.add(createAttributorCGSCCLegacyPass());
// Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
@ -888,7 +895,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
PM.add(createCalledValuePropagationPass());
// Infer attributes on declarations, call sites, arguments, etc.
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::MODULE)
PM.add(createAttributorLegacyPass());
}
@ -943,7 +950,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
addPGOInstrPasses(PM, /* IsCS */ true);
// Infer attributes on declarations, call sites, arguments, etc. for an SCC.
if (!DisableAttributor)
if (AttributorRun & AttributorRunOption::CGSCC)
PM.add(createAttributorCGSCCLegacyPass());
// Try to perform OpenMP specific optimizations. This is a (quick!) no-op if