Skip to content

Commit

Permalink
[NewPM][Pipeline] Add PipelineTuningOption to set inliner threshold
Browse files Browse the repository at this point in the history
The legacy PM allowed you to set a custom inliner threshold via
  builder.Inliner = llvm::createFunctionInliningPass(inline_threshold);

This allows the same thing to be done with the new PM optimization pipelines.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D137038
  • Loading branch information
aeubanks committed Nov 2, 2022
1 parent 76b04c2 commit 4fa3280
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions llvm/include/llvm/Passes/PassBuilder.h
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion llvm/lib/Passes/PassBuilderPipelines.cpp
Expand Up @@ -200,6 +200,7 @@ PipelineTuningOptions::PipelineTuningOptions() {
LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
CallGraphProfile = true;
MergeFunctions = EnableMergeFunctions;
InlinerThreshold = -1;
EagerlyInvalidateAnalyses = EnableEagerlyInvalidateAnalyses;
}

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4fa3280

Please sign in to comment.