[InlineAdvisor] Add option to control deferred inlining (NFC)

This change is split out from D115497 to add the option
independently from the switch of the default value.
This commit is contained in:
Nikita Popov 2021-12-14 15:42:33 +01:00
parent 8002fa6760
commit 7abf299fed
2 changed files with 8 additions and 3 deletions

View File

@ -212,7 +212,7 @@ struct InlineParams {
Optional<bool> ComputeFullInlineCost;
/// Indicate whether we should allow inline deferral.
Optional<bool> EnableDeferral = true;
Optional<bool> EnableDeferral;
/// Indicate whether we allow inlining for recursive call.
Optional<bool> AllowRecursiveCall = false;

View File

@ -40,6 +40,10 @@ static cl::opt<bool>
" callsites processed by inliner but decided"
" to be not inlined"));
static cl::opt<bool> EnableInlineDeferral("inline-deferral", cl::init(true),
cl::Hidden,
cl::desc("Enable deferred inlining"));
// An integer used to limit the cost of inline deferral. The default negative
// number tells shouldBeDeferred to only take the secondary cost into account.
static cl::opt<int>
@ -136,8 +140,9 @@ llvm::Optional<llvm::InlineCost> static getDefaultInlineAdvice(
return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI,
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
};
return llvm::shouldInline(CB, GetInlineCost, ORE,
Params.EnableDeferral.getValueOr(false));
return llvm::shouldInline(
CB, GetInlineCost, ORE,
Params.EnableDeferral.getValueOr(EnableInlineDeferral));
}
std::unique_ptr<InlineAdvice>