Go to the documentation of this file.
13 #ifndef LLVM_ANALYSIS_INLINECOST_H
14 #define LLVM_ANALYSIS_INLINECOST_H
25 class AssumptionCache;
26 class OptimizationRemarkEmitter;
27 class BlockFrequencyInfo;
31 class ProfileSummaryInfo;
32 class TargetTransformInfo;
33 class TargetLibraryInfo;
35 namespace InlineConstants {
60 "function-inline-cost-multiplier";
88 enum SentinelValues { AlwaysInlineCost = INT_MIN, NeverInlineCost = INT_MAX };
97 const char *Reason =
nullptr;
103 InlineCost(
int Cost,
int Threshold,
const char *Reason =
nullptr,
105 : Cost(Cost), Threshold(Threshold), Reason(Reason),
106 CostBenefit(CostBenefit) {
108 "Reason must be provided for Never or Always");
113 assert(Cost > AlwaysInlineCost &&
"Cost crosses sentinel value");
114 assert(Cost < NeverInlineCost &&
"Cost crosses sentinel value");
119 return InlineCost(AlwaysInlineCost, 0, Reason, CostBenefit);
123 return InlineCost(NeverInlineCost, 0, Reason, CostBenefit);
127 explicit operator bool()
const {
return Cost < Threshold; }
129 bool isAlways()
const {
return Cost == AlwaysInlineCost; }
130 bool isNever()
const {
return Cost == NeverInlineCost; }
152 "InlineCost reason must be set for Always or Never");
165 const char *Message =
nullptr;
166 InlineResult(
const char *Message =
nullptr) : Message(Message) {}
176 "getFailureReason should only be called in failure cases");
A set of analyses that are preserved following a run of a transformation pass.
int getCost() const
Get the inline cost estimate.
static InlineResult success()
InlineCostAnnotationPrinterPass(raw_ostream &OS)
This is an optimization pass for GlobalISel generic memory operations.
Optional< int > getStringFnAttrAsInt(CallBase &CB, StringRef AttrKind)
A parsed version of the target data layout string in and methods for querying it.
int DefaultThreshold
The default threshold to start with for a callee.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Optional< int > LocallyHotCallSiteThreshold
Threshold to use when the callsite is considered hot relative to function entry.
FunctionAnalysisManager FAM
const int OptSizeThreshold
Use when optsize (-Os) is specified.
static InlineCost getAlways(const char *Reason, Optional< CostBenefitPair > CostBenefit=None)
InlineResult isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
Thresholds to tune inline cost analysis.
int getThreshold() const
Get the threshold against which the cost was computed.
const char FunctionInlineCostMultiplierAttributeName[]
Optional< int > ColdThreshold
Threshold to use for cold callees.
Optional< int > OptMinSizeThreshold
Threshold to use when the caller is optimized for minsize.
Optional< bool > ComputeFullInlineCost
Compute inline cost even when the cost has exceeded the threshold.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
InlineCost getInlineCost(CallBase &Call, const InlineParams &Params, TargetTransformInfo &CalleeTTI, function_ref< AssumptionCache &(Function &)> GetAssumptionCache, function_ref< const TargetLibraryInfo &(Function &)> GetTLI, function_ref< BlockFrequencyInfo &(Function &)> GetBFI=nullptr, ProfileSummaryInfo *PSI=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Get an InlineCost object representing the cost of inlining this callsite.
Represents the cost of inlining a function.
This class implements an extremely fast bulk output stream that can only output to a stream.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
static InlineCost get(int Cost, int Threshold)
InlineParams getInlineParams()
Generate the parameters to tune the inline cost analysis based only on the commandline options.
Analysis providing profile information.
An efficient, type-erasing, non-owning reference to a callable.
const int IndirectCallThreshold
const int OptAggressiveThreshold
Use when -O3 is specified.
int getCostDelta() const
Get the cost delta from the threshold for inlining.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Optional< int > ColdCallSiteThreshold
Threshold to use when the callsite is considered cold.
static InlineCost getNever(const char *Reason, Optional< CostBenefitPair > CostBenefit=None)
Class for arbitrary precision integers.
StringRef - Represent a constant reference to a string, i.e.
const char * getReason() const
Get the reason of Always or Never.
A cache of @llvm.assume calls within a function.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const char * getFailureReason() const
const uint64_t MaxSimplifiedDynamicAllocaToInline
Do not inline dynamic allocas that have been constant propagated to be static allocas above this amou...
Optional< InlineResult > getAttributeBasedInliningDecision(CallBase &Call, Function *Callee, TargetTransformInfo &CalleeTTI, function_ref< const TargetLibraryInfo &(Function &)> GetTLI)
Returns InlineResult::success() if the call site should be always inlined because of user directives,...
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
Optional< InlineCostFeatures > getInliningCostFeatures(CallBase &Call, TargetTransformInfo &CalleeTTI, function_ref< AssumptionCache &(Function &)> GetAssumptionCache, function_ref< BlockFrequencyInfo &(Function &)> GetBFI=nullptr, ProfileSummaryInfo *PSI=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Get the expanded cost features.
Optional< CostBenefitPair > getCostBenefit() const
Get the cost-benefit pair which was computed by cost-benefit analysis.
CostBenefitPair(APInt Cost, APInt Benefit)
const APInt & getCost() const
Provides information about what library functions are available for the current target.
static InlineResult failure(const char *Reason)
const int OptMinSizeThreshold
Use when minsize (-Oz) is specified.
Optional< int > getInliningCostEstimate(CallBase &Call, TargetTransformInfo &CalleeTTI, function_ref< AssumptionCache &(Function &)> GetAssumptionCache, function_ref< BlockFrequencyInfo &(Function &)> GetBFI=nullptr, ProfileSummaryInfo *PSI=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Get the cost estimate ignoring thresholds.
int getCallsiteCost(CallBase &Call, const DataLayout &DL)
Return the cost associated with a callsite, including parameter passing and the call/return instructi...
const int LastCallToStaticBonus
const APInt & getBenefit() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A container for analyses that lazily runs them and caches their results.
Optional< int > HotCallSiteThreshold
Threshold to use when the callsite is considered hot.
const unsigned TotalAllocaSizeRecursiveCaller
Do not inline functions which allocate this many bytes on the stack when the caller is recursive.
Optional< bool > EnableDeferral
Indicate whether we should allow inline deferral.
Optional< bool > AllowRecursiveCall
Indicate whether we allow inlining for recursive call.
InlineResult is basically true or false.
Optional< int > OptSizeThreshold
Threshold to use when the caller is optimized for size.