13 #ifndef LLVM_ANALYSIS_INLINECOST_H 14 #define LLVM_ANALYSIS_INLINECOST_H 23 class AssumptionCacheTracker;
24 class BlockFrequencyInfo;
28 class ProfileSummaryInfo;
29 class TargetTransformInfo;
31 namespace InlineConstants {
65 AlwaysInlineCost = INT_MIN,
66 NeverInlineCost = INT_MAX
76 const char *Reason =
nullptr;
79 InlineCost(
int Cost,
int Threshold,
const char *Reason =
nullptr)
80 : Cost(Cost),
Threshold(Threshold), Reason(Reason) {
81 assert((isVariable() || Reason) &&
82 "Reason must be provided for Never or Always");
87 assert(Cost > AlwaysInlineCost &&
"Cost crosses sentinel value");
88 assert(Cost < NeverInlineCost &&
"Cost crosses sentinel value");
92 return InlineCost(AlwaysInlineCost, 0, Reason);
99 explicit operator bool()
const {
103 bool isAlways()
const {
return Cost == AlwaysInlineCost; }
104 bool isNever()
const {
return Cost == NeverInlineCost; }
105 bool isVariable()
const {
return !isAlways() && !isNever(); }
110 assert(isVariable() &&
"Invalid access of InlineCost");
116 assert(isVariable() &&
"Invalid access of InlineCost");
122 assert((Reason || isVariable()) &&
123 "InlineCost reason must be set for Always or Never");
136 const char *message =
nullptr;
138 : message(result ? nullptr : (message ? message :
"cost > threshold")) {}
140 operator bool()
const {
return !message; }
141 operator const char *()
const {
return message; }
A parsed version of the target data layout string in and methods for querying it. ...
Thresholds to tune inline cost analysis.
InlineCost getInlineCost(CallBase &Call, const InlineParams &Params, TargetTransformInfo &CalleeTTI, std::function< AssumptionCache &(Function &)> &GetAssumptionCache, Optional< function_ref< BlockFrequencyInfo &(Function &)>> GetBFI, ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE=nullptr)
Get an InlineCost object representing the cost of inlining this callsite.
This class represents lattice values for constants.
Optional< int > OptSizeThreshold
Threshold to use when the caller is optimized for size.
Analysis providing profile information.
const int OptMinSizeThreshold
Use when minsize (-Oz) is specified.
An efficient, type-erasing, non-owning reference to a callable.
A cache of @llvm.assume calls within a function.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Represents the cost of inlining a function.
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
const int LastCallToStaticBonus
static InlineCost getAlways(const char *Reason)
InlineResult is basically true or false.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
const int IndirectCallThreshold
const int OptAggressiveThreshold
Use when -O3 is specified.
Optional< int > OptMinSizeThreshold
Threshold to use when the caller is optimized for minsize.
InlineResult(bool result, const char *message=nullptr)
InlineResult isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
Optional< int > LocallyHotCallSiteThreshold
Threshold to use when the callsite is considered hot relative to function entry.
int getThreshold() const
Get the threshold against which the cost was computed.
const char * getReason() const
Get the reason of Always or Never.
Optional< bool > ComputeFullInlineCost
Compute inline cost even when the cost has exceeded the threshold.
InlineParams getInlineParams()
Generate the parameters to tune the inline cost analysis based only on the commandline options...
Optional< int > ColdThreshold
Threshold to use for cold callees.
int getCallsiteCost(CallBase &Call, const DataLayout &DL)
Return the cost associated with a callsite, including parameter passing and the call/return instructi...
int getCost() const
Get the inline cost estimate.
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
int getCostDelta() const
Get the cost delta from the threshold for inlining.
static InlineCost getNever(const char *Reason)
const unsigned TotalAllocaSizeRecursiveCaller
Do not inline functions which allocate this many bytes on the stack when the caller is recursive...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Optional< int > ColdCallSiteThreshold
Threshold to use when the callsite is considered cold.
print Print MemDeps of function
InlineResult(const char *message=nullptr)
const int OptSizeThreshold
Use when optsize (-Os) is specified.
Optional< int > HotCallSiteThreshold
Threshold to use when the callsite is considered hot.
int DefaultThreshold
The default threshold to start with for a callee.