diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h index 68f07f39afa635..d7d76c30d1a6bb 100644 --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -75,6 +75,9 @@ class PipelineTuningOptions { /// false. bool MergeFunctions; + /// Tuning option to override the default inliner threshold. + int InlinerThreshold; + // Experimental option to eagerly invalidate more analyses. This has the // potential to decrease max memory usage in exchange for more compile time. // This may affect codegen due to either passes using analyses only when diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 4f1ef22775db8b..b32d53d8dfaf8d 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -200,6 +200,7 @@ PipelineTuningOptions::PipelineTuningOptions() { LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; CallGraphProfile = true; MergeFunctions = EnableMergeFunctions; + InlinerThreshold = -1; EagerlyInvalidateAnalyses = EnableEagerlyInvalidateAnalyses; } @@ -719,7 +720,11 @@ static InlineParams getInlineParamsFromOptLevel(OptimizationLevel Level) { ModuleInlinerWrapperPass PassBuilder::buildInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase) { - InlineParams IP = getInlineParamsFromOptLevel(Level); + InlineParams IP; + if (PTO.InlinerThreshold == -1) + IP = getInlineParamsFromOptLevel(Level); + else + IP = getInlineParams(PTO.InlinerThreshold); // For PreLinkThinLTO + SamplePGO, set hot-caller threshold to 0 to // disable hot callsite inline (as much as possible [1]) because it makes // profile annotation in the backend inaccurate.