diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -2862,6 +2862,14 @@ 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 diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -258,7 +258,7 @@ extern cl::opt FlattenedProfileUsed; -extern cl::opt DisableAttributor; +extern cl::opt AttributorRun; const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = { /*SpeedLevel*/ 0, @@ -768,7 +768,7 @@ true /* SamplePGO */)); } - if (!DisableAttributor) + if (AttributorRun & AttributorRunOption::MODULE) MPM.addPass(AttributorPass()); // Interprocedural constant propagation now that basic cleanup has occurred @@ -852,7 +852,7 @@ IP.HotCallSiteThreshold = 0; MainCGPipeline.addPass(InlinerPass(IP)); - if (!DisableAttributor) + if (AttributorRun & AttributorRunOption::CGSCC) MainCGPipeline.addPass(AttributorCGSCCPass()); if (PTO.Coroutines) diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -153,10 +153,17 @@ EnableMatrix("enable-matrix", cl::init(false), cl::Hidden, cl::desc("Enable lowering of the matrix intrinsics")); -cl::opt DisableAttributor( - "attributor-disable", cl::Hidden, - cl::desc("Disable the attributor inter-procedural deduction pass."), - cl::init(true)); +cl::opt 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 @@ 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 @@ } // 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 @@ PM.add(createCalledValuePropagationPass()); // Infer attributes on declarations, call sites, arguments, etc. - if (!DisableAttributor) + if (AttributorRun & AttributorRunOption::MODULE) PM.add(createAttributorLegacyPass()); } @@ -943,7 +950,7 @@ 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