Skip to content

Commit 11046ef

Browse files
committed
[llvm][NFC] Factored the default inlining advice
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.
1 parent 3780d3e commit 11046ef

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

llvm/lib/Analysis/InlineAdvisor.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class DefaultInlineAdvice : public InlineAdvice {
8484

8585
} // namespace
8686

87-
std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
87+
llvm::Optional<llvm::InlineCost>
88+
getDefaultInlineAdvice(CallBase &CB, FunctionAnalysisManager &FAM,
89+
const InlineParams &Params) {
8890
Function &Caller = *CB.getCaller();
8991
ProfileSummaryInfo *PSI =
9092
FAM.getResult<ModuleAnalysisManagerFunctionProxy>(Caller)
@@ -111,10 +113,16 @@ std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
111113
return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI,
112114
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
113115
};
114-
auto OIC = llvm::shouldInline(CB, GetInlineCost, ORE,
115-
Params.EnableDeferral.hasValue() &&
116-
Params.EnableDeferral.getValue());
117-
return std::make_unique<DefaultInlineAdvice>(this, CB, OIC, ORE);
116+
return llvm::shouldInline(CB, GetInlineCost, ORE,
117+
Params.EnableDeferral.hasValue() &&
118+
Params.EnableDeferral.getValue());
119+
}
120+
121+
std::unique_ptr<InlineAdvice> DefaultInlineAdvisor::getAdvice(CallBase &CB) {
122+
auto OIC = getDefaultInlineAdvice(CB, FAM, Params);
123+
return std::make_unique<DefaultInlineAdvice>(
124+
this, CB, OIC,
125+
FAM.getResult<OptimizationRemarkEmitterAnalysis>(*CB.getCaller()));
118126
}
119127

120128
InlineAdvice::InlineAdvice(InlineAdvisor *Advisor, CallBase &CB,

0 commit comments

Comments
 (0)