diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -88,6 +88,18 @@ "inline-enable-cost-benefit-analysis", cl::Hidden, cl::init(false), cl::desc("Enable the cost-benefit analysis for the inliner")); +static cl::opt EnableHybridAnalysis( + "inline-hybrid-analysis", cl::init(false), cl::Hidden, + cl::desc("If set to true, a hybrid of cost-benefit analysis and " + "cost-threshold analysis is used. In parctice, a hybrid model " + "should be used when machine-functions-splitter is not enabled.")); + +static cl::opt AggressiveInlineSavingsMultiplier( + "aggressive-inline-savings-multiplier", cl::Hidden, cl::init(3), + cl::desc("The multiplier to multiply cycle savings. If a callee's cycle " + "saving is greater than cost using this multiplier, it's a " + "stronger signal that inlining this callee is useful")); + static cl::opt InlineSavingsMultiplier( "inline-savings-multiplier", cl::Hidden, cl::init(8), cl::desc("Multiplier to multiply cycle savings by during inlining")); @@ -898,10 +910,19 @@ // Note that the left hand side is specific to a call site. The right hand // side is a constant for the entire executable. APInt LHS = CycleSavings; - LHS *= InlineSavingsMultiplier; + LHS *= AggressiveInlineSavingsMultiplier; APInt RHS(128, PSI->getOrCompHotCountThreshold()); RHS *= Size; - return LHS.uge(RHS); + if (LHS.uge(RHS)) + return true; + + APInt ConservativeLHS = CycleSavings; + ConservativeLHS *= InlineSavingsMultiplier; + + if (!ConservativeLHS.uge(RHS)) + return false; + + return std::nullopt; } InlineResult finalizeAnalysis() override {