LLVM 22.0.0git
InlineCost.cpp File Reference

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::InlineConstants

Macros

#define DEBUG_TYPE   "inline-cost"
#define DEBUG_PRINT_STAT(x)

Functions

 STATISTIC (NumCallsAnalyzed, "Number of call sites analyzed")
std::optional< int > llvm::getStringFnAttrAsInt (const Attribute &Attr)
LLVM_ABI std::optional< int > llvm::getStringFnAttrAsInt (CallBase &CB, StringRef AttrKind)
std::optional< int > llvm::getStringFnAttrAsInt (Function *F, StringRef AttrKind)
LLVM_ABI int llvm::InlineConstants::getInstrCost ()
static bool functionsHaveCompatibleAttributes (Function *Caller, Function *Callee, TargetTransformInfo &TTI, function_ref< const TargetLibraryInfo &(Function &)> &GetTLI)
 Test that there are no attribute conflicts between Caller and Callee that prevent inlining.
static int computeThresholdFromOptLevels (unsigned OptLevel, unsigned SizeOptLevel)

Variables

static cl::opt< int > DefaultThreshold ("inlinedefault-threshold", cl::Hidden, cl::init(225), cl::desc("Default amount of inlining to perform"))
static cl::opt< boolIgnoreTTIInlineCompatible ("ignore-tti-inline-compatible", cl::Hidden, cl::init(false), cl::desc("Ignore TTI attributes compatibility check between callee/caller " "during inline cost calculation"))
static cl::opt< boolPrintInstructionComments ("print-instruction-comments", cl::Hidden, cl::init(false), cl::desc("Prints comments for instruction based on inline cost analysis"))
static cl::opt< int > InlineThreshold ("inline-threshold", cl::Hidden, cl::init(225), cl::desc("Control the amount of inlining to perform (default = 225)"))
static cl::opt< int > HintThreshold ("inlinehint-threshold", cl::Hidden, cl::init(325), cl::desc("Threshold for inlining functions with inline hint"))
static cl::opt< int > ColdCallSiteThreshold ("inline-cold-callsite-threshold", cl::Hidden, cl::init(45), cl::desc("Threshold for inlining cold callsites"))
static cl::opt< boolInlineEnableCostBenefitAnalysis ("inline-enable-cost-benefit-analysis", cl::Hidden, cl::init(false), cl::desc("Enable the cost-benefit analysis for the inliner"))
static cl::opt< int > InlineSavingsMultiplier ("inline-savings-multiplier", cl::Hidden, cl::init(8), cl::desc("Multiplier to multiply cycle savings by during inlining"))
static cl::opt< int > InlineSavingsProfitableMultiplier ("inline-savings-profitable-multiplier", cl::Hidden, cl::init(4), cl::desc("A multiplier on top of cycle savings to decide whether the " "savings won't justify the cost"))
static cl::opt< int > InlineSizeAllowance ("inline-size-allowance", cl::Hidden, cl::init(100), cl::desc("The maximum size of a callee that get's " "inlined without sufficient cycle savings"))
static cl::opt< int > ColdThreshold ("inlinecold-threshold", cl::Hidden, cl::init(45), cl::desc("Threshold for inlining functions with cold attribute"))
static cl::opt< int > HotCallSiteThreshold ("hot-callsite-threshold", cl::Hidden, cl::init(3000), cl::desc("Threshold for hot callsites "))
static cl::opt< int > LocallyHotCallSiteThreshold ("locally-hot-callsite-threshold", cl::Hidden, cl::init(525), cl::desc("Threshold for locally hot callsites "))
static cl::opt< int > ColdCallSiteRelFreq ("cold-callsite-rel-freq", cl::Hidden, cl::init(2), cl::desc("Maximum block frequency, expressed as a percentage of caller's " "entry frequency, for a callsite to be cold in the absence of " "profile information."))
static cl::opt< uint64_tHotCallSiteRelFreq ("hot-callsite-rel-freq", cl::Hidden, cl::init(60), cl::desc("Minimum block frequency, expressed as a multiple of caller's " "entry frequency, for a callsite to be hot in the absence of " "profile information."))
static cl::opt< int > InstrCost ("inline-instr-cost", cl::Hidden, cl::init(5), cl::desc("Cost of a single instruction when inlining"))
static cl::opt< int > InlineAsmInstrCost ("inline-asm-instr-cost", cl::Hidden, cl::init(0), cl::desc("Cost of a single inline asm instruction when inlining"))
static cl::opt< int > MemAccessCost ("inline-memaccess-cost", cl::Hidden, cl::init(0), cl::desc("Cost of load/store instruction when inlining"))
static cl::opt< int > CallPenalty ("inline-call-penalty", cl::Hidden, cl::init(25), cl::desc("Call penalty that is applied per callsite when inlining"))
static cl::opt< size_t > StackSizeThreshold ("inline-max-stacksize", cl::Hidden, cl::init(std::numeric_limits< size_t >::max()), cl::desc("Do not inline functions with a stack size " "that exceeds the specified limit"))
static cl::opt< size_t > RecurStackSizeThreshold ("recursive-inline-max-stacksize", cl::Hidden, cl::init(InlineConstants::TotalAllocaSizeRecursiveCaller), cl::desc("Do not inline recursive functions with a stack " "size that exceeds the specified limit"))
static cl::opt< boolOptComputeFullInlineCost ("inline-cost-full", cl::Hidden, cl::desc("Compute the full inline cost of a call site even when the cost " "exceeds the threshold."))
static cl::opt< boolInlineCallerSupersetNoBuiltin ("inline-caller-superset-nobuiltin", cl::Hidden, cl::init(true), cl::desc("Allow inlining when caller has a superset of callee's nobuiltin " "attributes."))
static cl::opt< boolDisableGEPConstOperand ("disable-gep-const-evaluation", cl::Hidden, cl::init(false), cl::desc("Disables evaluation of GetElementPtr with constant operands"))
static cl::opt< boolInlineAllViableCalls ("inline-all-viable-calls", cl::Hidden, cl::init(false), cl::desc("Inline all viable calls, even if they exceed the inlining " "threshold"))

Macro Definition Documentation

◆ DEBUG_PRINT_STAT

#define DEBUG_PRINT_STAT ( x)
Value:
OS << " " #x ": " << x << "\n"

◆ DEBUG_TYPE

#define DEBUG_TYPE   "inline-cost"

Definition at line 55 of file InlineCost.cpp.

Function Documentation

◆ computeThresholdFromOptLevels()

int computeThresholdFromOptLevels ( unsigned OptLevel,
unsigned SizeOptLevel )
static

◆ functionsHaveCompatibleAttributes()

bool functionsHaveCompatibleAttributes ( Function * Caller,
Function * Callee,
TargetTransformInfo & TTI,
function_ref< const TargetLibraryInfo &(Function &)> & GetTLI )
static

Test that there are no attribute conflicts between Caller and Callee that prevent inlining.

Definition at line 3083 of file InlineCost.cpp.

References IgnoreTTIInlineCompatible, and InlineCallerSupersetNoBuiltin.

Referenced by llvm::getAttributeBasedInliningDecision().

◆ STATISTIC()

STATISTIC ( NumCallsAnalyzed ,
"Number of call sites analyzed"  )

Variable Documentation

◆ CallPenalty

cl::opt< int > CallPenalty("inline-call-penalty", cl::Hidden, cl::init(25), cl::desc("Call penalty that is applied per callsite when inlining")) ( "inline-call-penalty" ,
cl::Hidden ,
cl::init(25) ,
cl::desc("Call penalty that is applied per callsite when inlining")  )
static

Referenced by llvm::getCallsiteCost().

◆ ColdCallSiteRelFreq

cl::opt< int > ColdCallSiteRelFreq("cold-callsite-rel-freq", cl::Hidden, cl::init(2), cl::desc("Maximum block frequency, expressed as a percentage of caller's " "entry frequency, for a callsite to be cold in the absence of " "profile information.")) ( "cold-callsite-rel-freq" ,
cl::Hidden ,
cl::init(2) ,
cl::desc("Maximum block frequency, expressed as a percentage of caller's " "entry frequency, for a callsite to be cold in the absence of " "profile information.")  )
static

◆ ColdCallSiteThreshold

cl::opt< int > ColdCallSiteThreshold("inline-cold-callsite-threshold", cl::Hidden, cl::init(45), cl::desc("Threshold for inlining cold callsites")) ( "inline-cold-callsite-threshold" ,
cl::Hidden ,
cl::init(45) ,
cl::desc("Threshold for inlining cold callsites")  )
static

Referenced by llvm::getInlineParams().

◆ ColdThreshold

cl::opt< int > ColdThreshold("inlinecold-threshold", cl::Hidden, cl::init(45), cl::desc("Threshold for inlining functions with cold attribute")) ( "inlinecold-threshold" ,
cl::Hidden ,
cl::init(45) ,
cl::desc("Threshold for inlining functions with cold attribute")  )
static

Referenced by llvm::getInlineParams().

◆ DefaultThreshold

cl::opt< int > DefaultThreshold("inlinedefault-threshold", cl::Hidden, cl::init(225), cl::desc("Default amount of inlining to perform")) ( "inlinedefault-threshold" ,
cl::Hidden ,
cl::init(225) ,
cl::desc("Default amount of inlining to perform")  )
static

◆ DisableGEPConstOperand

cl::opt< bool > DisableGEPConstOperand("disable-gep-const-evaluation", cl::Hidden, cl::init(false), cl::desc("Disables evaluation of GetElementPtr with constant operands")) ( "disable-gep-const-evaluation" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Disables evaluation of GetElementPtr with constant operands")  )
static

◆ HintThreshold

cl::opt< int > HintThreshold("inlinehint-threshold", cl::Hidden, cl::init(325), cl::desc("Threshold for inlining functions with inline hint")) ( "inlinehint-threshold" ,
cl::Hidden ,
cl::init(325) ,
cl::desc("Threshold for inlining functions with inline hint")  )
static

Referenced by llvm::getInlineParams().

◆ HotCallSiteRelFreq

cl::opt< uint64_t > HotCallSiteRelFreq("hot-callsite-rel-freq", cl::Hidden, cl::init(60), cl::desc("Minimum block frequency, expressed as a multiple of caller's " "entry frequency, for a callsite to be hot in the absence of " "profile information.")) ( "hot-callsite-rel-freq" ,
cl::Hidden ,
cl::init(60) ,
cl::desc("Minimum block frequency, expressed as a multiple of caller's " "entry frequency, for a callsite to be hot in the absence of " "profile information.")  )
static

◆ HotCallSiteThreshold

cl::opt< int > HotCallSiteThreshold("hot-callsite-threshold", cl::Hidden, cl::init(3000), cl::desc("Threshold for hot callsites ")) ( "hot-callsite-threshold" ,
cl::Hidden ,
cl::init(3000) ,
cl::desc("Threshold for hot callsites ")  )
static

Referenced by llvm::getInlineParams().

◆ IgnoreTTIInlineCompatible

cl::opt< bool > IgnoreTTIInlineCompatible("ignore-tti-inline-compatible", cl::Hidden, cl::init(false), cl::desc("Ignore TTI attributes compatibility check between callee/caller " "during inline cost calculation")) ( "ignore-tti-inline-compatible" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Ignore TTI attributes compatibility check between callee/caller " "during inline cost calculation")  )
static

◆ InlineAllViableCalls

cl::opt< bool > InlineAllViableCalls("inline-all-viable-calls", cl::Hidden, cl::init(false), cl::desc("Inline all viable calls, even if they exceed the inlining " "threshold")) ( "inline-all-viable-calls" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Inline all viable calls, even if they exceed the inlining " "threshold")  )
static

Referenced by llvm::getInlineCost().

◆ InlineAsmInstrCost

cl::opt< int > InlineAsmInstrCost("inline-asm-instr-cost", cl::Hidden, cl::init(0), cl::desc("Cost of a single inline asm instruction when inlining")) ( "inline-asm-instr-cost" ,
cl::Hidden ,
cl::init(0) ,
cl::desc("Cost of a single inline asm instruction when inlining")  )
static

◆ InlineCallerSupersetNoBuiltin

cl::opt< bool > InlineCallerSupersetNoBuiltin("inline-caller-superset-nobuiltin", cl::Hidden, cl::init(true), cl::desc("Allow inlining when caller has a superset of callee's nobuiltin " "attributes.")) ( "inline-caller-superset-nobuiltin" ,
cl::Hidden ,
cl::init(true) ,
cl::desc("Allow inlining when caller has a superset of callee's nobuiltin " "attributes.")  )
static

◆ InlineEnableCostBenefitAnalysis

cl::opt< bool > InlineEnableCostBenefitAnalysis("inline-enable-cost-benefit-analysis", cl::Hidden, cl::init(false), cl::desc("Enable the cost-benefit analysis for the inliner")) ( "inline-enable-cost-benefit-analysis" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Enable the cost-benefit analysis for the inliner")  )
static

◆ InlineSavingsMultiplier

cl::opt< int > InlineSavingsMultiplier("inline-savings-multiplier", cl::Hidden, cl::init(8), cl::desc("Multiplier to multiply cycle savings by during inlining")) ( "inline-savings-multiplier" ,
cl::Hidden ,
cl::init(8) ,
cl::desc("Multiplier to multiply cycle savings by during inlining")  )
static

◆ InlineSavingsProfitableMultiplier

cl::opt< int > InlineSavingsProfitableMultiplier("inline-savings-profitable-multiplier", cl::Hidden, cl::init(4), cl::desc("A multiplier on top of cycle savings to decide whether the " "savings won't justify the cost")) ( "inline-savings-profitable-multiplier" ,
cl::Hidden ,
cl::init(4) ,
cl::desc("A multiplier on top of cycle savings to decide whether the " "savings won't justify the cost")  )
static

◆ InlineSizeAllowance

cl::opt< int > InlineSizeAllowance("inline-size-allowance", cl::Hidden, cl::init(100), cl::desc("The maximum size of a callee that get's " "inlined without sufficient cycle savings")) ( "inline-size-allowance" ,
cl::Hidden ,
cl::init(100) ,
cl::desc("The maximum size of a callee that get's " "inlined without sufficient cycle savings")  )
static

◆ InlineThreshold

cl::opt< int > InlineThreshold("inline-threshold", cl::Hidden, cl::init(225), cl::desc("Control the amount of inlining to perform (default = 225)")) ( "inline-threshold" ,
cl::Hidden ,
cl::init(225) ,
cl::desc("Control the amount of inlining to perform (default = 225)")  )
static

Referenced by llvm::getInlineParams().

◆ InstrCost

cl::opt< int > InstrCost("inline-instr-cost", cl::Hidden, cl::init(5), cl::desc("Cost of a single instruction when inlining")) ( "inline-instr-cost" ,
cl::Hidden ,
cl::init(5) ,
cl::desc("Cost of a single instruction when inlining")  )
static

◆ LocallyHotCallSiteThreshold

cl::opt< int > LocallyHotCallSiteThreshold("locally-hot-callsite-threshold", cl::Hidden, cl::init(525), cl::desc("Threshold for locally hot callsites ")) ( "locally-hot-callsite-threshold" ,
cl::Hidden ,
cl::init(525) ,
cl::desc("Threshold for locally hot callsites ")  )
static

◆ MemAccessCost

cl::opt< int > MemAccessCost("inline-memaccess-cost", cl::Hidden, cl::init(0), cl::desc("Cost of load/store instruction when inlining")) ( "inline-memaccess-cost" ,
cl::Hidden ,
cl::init(0) ,
cl::desc("Cost of load/store instruction when inlining")  )
static

◆ OptComputeFullInlineCost

cl::opt< bool > OptComputeFullInlineCost("inline-cost-full", cl::Hidden, cl::desc("Compute the full inline cost of a call site even when the cost " "exceeds the threshold.")) ( "inline-cost-full" ,
cl::Hidden ,
cl::desc("Compute the full inline cost of a call site even when the cost " "exceeds the threshold.")  )
static

◆ PrintInstructionComments

cl::opt< bool > PrintInstructionComments("print-instruction-comments", cl::Hidden, cl::init(false), cl::desc("Prints comments for instruction based on inline cost analysis")) ( "print-instruction-comments" ,
cl::Hidden ,
cl::init(false) ,
cl::desc("Prints comments for instruction based on inline cost analysis")  )
static

◆ RecurStackSizeThreshold

cl::opt< size_t > RecurStackSizeThreshold("recursive-inline-max-stacksize", cl::Hidden, cl::init(InlineConstants::TotalAllocaSizeRecursiveCaller), cl::desc("Do not inline recursive functions with a stack " "size that exceeds the specified limit")) ( "recursive-inline-max-stacksize" ,
cl::Hidden ,
cl::init(InlineConstants::TotalAllocaSizeRecursiveCaller) ,
cl::desc("Do not inline recursive functions with a stack " "size that exceeds the specified limit")  )
static

◆ StackSizeThreshold

cl::opt< size_t > StackSizeThreshold("inline-max-stacksize", cl::Hidden, cl::init(std::numeric_limits< size_t >::max()), cl::desc("Do not inline functions with a stack size " "that exceeds the specified limit")) ( "inline-max-stacksize" ,
cl::Hidden ,
cl::init(std::numeric_limits< size_t >::max()) ,
cl::desc("Do not inline functions with a stack size " "that exceeds the specified limit")  )
static