Index: llvm/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/lib/Passes/PassBuilder.cpp +++ llvm/lib/Passes/PassBuilder.cpp @@ -253,6 +253,8 @@ extern cl::opt FlattenedProfileUsed; +extern cl::opt DisableAttributor; + const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = { /*SpeedLevel*/ 0, /*SizeLevel*/ 0}; @@ -760,7 +762,9 @@ MPM.addPass(PGOIndirectCallPromotion(Phase == ThinLTOPhase::PostLink, true /* SamplePGO */)); } - MPM.addPass(AttributorPass()); + + if (!DisableAttributor) + MPM.addPass(AttributorPass()); // Interprocedural constant propagation now that basic cleanup has occurred // and prior to optimizing globals. @@ -843,7 +847,8 @@ IP.HotCallSiteThreshold = 0; MainCGPipeline.addPass(InlinerPass(IP)); - MainCGPipeline.addPass(AttributorCGSCCPass()); + if (!DisableAttributor) + MainCGPipeline.addPass(AttributorCGSCCPass()); if (PTO.Coroutines) MainCGPipeline.addPass(CoroSplitPass()); Index: llvm/lib/Transforms/IPO/Attributor.cpp =================================================================== --- llvm/lib/Transforms/IPO/Attributor.cpp +++ llvm/lib/Transforms/IPO/Attributor.cpp @@ -158,11 +158,6 @@ cl::desc("Verify that max-iterations is a tight bound for a fixpoint"), cl::init(false)); -static cl::opt DisableAttributor( - "attributor-disable", cl::Hidden, - cl::desc("Disable the attributor inter-procedural deduction pass."), - cl::init(true)); - static cl::opt AnnotateDeclarationCallSites( "attributor-annotate-decl-cs", cl::Hidden, cl::desc("Annotate call sites of function declarations."), cl::init(false)); @@ -8582,7 +8577,7 @@ SetVector &Functions, AnalysisGetter &AG, CallGraphUpdater &CGUpdater) { - if (DisableAttributor || Functions.empty()) + if (Functions.empty()) return false; LLVM_DEBUG(dbgs() << "[Attributor] Run on module with " << Functions.size() Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -153,6 +153,11 @@ 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)); + PassManagerBuilder::PassManagerBuilder() { OptLevel = 2; SizeLevel = 0; @@ -553,7 +558,8 @@ MPM.add(createInferFunctionAttrsLegacyPass()); // Infer attributes on declarations, call sites, arguments, etc. - MPM.add(createAttributorLegacyPass()); + if (!DisableAttributor) + MPM.add(createAttributorLegacyPass()); addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); @@ -601,7 +607,8 @@ } // Infer attributes on declarations, call sites, arguments, etc. for an SCC. - MPM.add(createAttributorCGSCCLegacyPass()); + if (!DisableAttributor) + MPM.add(createAttributorCGSCCLegacyPass()); // Try to perform OpenMP specific optimizations. This is a (quick!) no-op if // there are no OpenMP runtime calls present in the module. @@ -887,7 +894,8 @@ PM.add(createCalledValuePropagationPass()); // Infer attributes on declarations, call sites, arguments, etc. - PM.add(createAttributorLegacyPass()); + if (!DisableAttributor) + PM.add(createAttributorLegacyPass()); } // Infer attributes about definitions. The readnone attribute in particular is @@ -941,7 +949,8 @@ addPGOInstrPasses(PM, /* IsCS */ true); // Infer attributes on declarations, call sites, arguments, etc. for an SCC. - PM.add(createAttributorCGSCCLegacyPass()); + if (!DisableAttributor) + PM.add(createAttributorCGSCCLegacyPass()); // Try to perform OpenMP specific optimizations. This is a (quick!) no-op if // there are no OpenMP runtime calls present in the module.