Skip to content

Commit

Permalink
[llvm][NFC] Factored the default inlining advice
Browse files Browse the repository at this point in the history
This is in preparation for the 'development' mode advisor. We currently
want to track what the default policy's decision would have been, this
refactoring makes it easier to do that.
  • Loading branch information
mtrofin committed Jul 13, 2020
1 parent 3780d3e commit 11046ef
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions llvm/lib/Analysis/InlineAdvisor.cpp
Expand Up @@ -84,7 +84,9 @@ class DefaultInlineAdvice : public InlineAdvice {

} // namespace

std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
llvm::Optional<llvm::InlineCost>
getDefaultInlineAdvice(CallBase &CB, FunctionAnalysisManager &FAM,
const InlineParams &Params) {
Function &Caller = *CB.getCaller();
ProfileSummaryInfo *PSI =
FAM.getResult<ModuleAnalysisManagerFunctionProxy>(Caller)
Expand All @@ -111,10 +113,16 @@ std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI,
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
};
auto OIC = llvm::shouldInline(CB, GetInlineCost, ORE,
Params.EnableDeferral.hasValue() &&
Params.EnableDeferral.getValue());
return std::make_unique<DefaultInlineAdvice>(this, CB, OIC, ORE);
return llvm::shouldInline(CB, GetInlineCost, ORE,
Params.EnableDeferral.hasValue() &&
Params.EnableDeferral.getValue());
}

std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
auto OIC = getDefaultInlineAdvice(CB, FAM, Params);
return std::make_unique<DefaultInlineAdvice>(
this, CB, OIC,
FAM.getResult<OptimizationRemarkEmitterAnalysis>(*CB.getCaller()));
}

InlineAdvice::InlineAdvice(InlineAdvisor *Advisor, CallBase &CB,
Expand Down

0 comments on commit 11046ef

Please sign in to comment.