14 #ifndef LLVM_ANALYSIS_INLINECOST_H 15 #define LLVM_ANALYSIS_INLINECOST_H 24 class AssumptionCacheTracker;
25 class BlockFrequencyInfo;
29 class ProfileSummaryInfo;
30 class TargetTransformInfo;
32 namespace InlineConstants {
66 AlwaysInlineCost = INT_MIN,
67 NeverInlineCost = INT_MAX
77 const char *Reason =
nullptr;
80 InlineCost(
int Cost,
int Threshold,
const char *Reason =
nullptr)
81 : Cost(Cost),
Threshold(Threshold), Reason(Reason) {
82 assert((isVariable() || Reason) &&
83 "Reason must be provided for Never or Always");
88 assert(Cost > AlwaysInlineCost &&
"Cost crosses sentinel value");
89 assert(Cost < NeverInlineCost &&
"Cost crosses sentinel value");
93 return InlineCost(AlwaysInlineCost, 0, Reason);
100 explicit operator bool()
const {
104 bool isAlways()
const {
return Cost == AlwaysInlineCost; }
105 bool isNever()
const {
return Cost == NeverInlineCost; }
106 bool isVariable()
const {
return !isAlways() && !isNever(); }
111 assert(isVariable() &&
"Invalid access of InlineCost");
117 assert(isVariable() &&
"Invalid access of InlineCost");
123 assert((Reason || isVariable()) &&
124 "InlineCost reason must be set for Always or Never");
137 const char *message =
nullptr;
139 : message(result ? nullptr : (message ? message :
"cost > threshold")) {}
141 operator bool()
const {
return !message; }
142 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.
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.
Represents the cost of inlining a function.
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
bool isInlineViable(Function &Callee)
Minimal filter to detect invalid constructs for inlining.
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)
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.
InlineCost getInlineCost(CallSite CS, 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.
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 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)
int getCallsiteCost(CallSite CS, const DataLayout &DL)
Return the cost associated with a callsite, including parameter passing and the call/return instructi...
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.