13#ifndef LLVM_ANALYSIS_INLINECOST_H 
   14#define LLVM_ANALYSIS_INLINECOST_H 
   61    "function-inline-cost-multiplier";
 
 
   92  enum SentinelValues { AlwaysInlineCost = INT_MIN, NeverInlineCost = INT_MAX };
 
  101  int StaticBonusApplied = 0;
 
  104  const char *Reason = 
nullptr;
 
  107  std::optional<CostBenefitPair> CostBenefit;
 
  110  InlineCost(
int Cost, 
int Threshold, 
int StaticBonusApplied,
 
  111             const char *Reason = 
nullptr,
 
  112             std::optional<CostBenefitPair> CostBenefit = std::nullopt)
 
  113      : 
Cost(Cost), Threshold(Threshold),
 
  114        StaticBonusApplied(StaticBonusApplied), Reason(Reason),
 
  117           "Reason must be provided for Never or Always");
 
  121  static InlineCost 
get(
int Cost, 
int Threshold, 
int StaticBonus = 0) {
 
  122    assert(Cost > AlwaysInlineCost && 
"Cost crosses sentinel value");
 
  123    assert(Cost < NeverInlineCost && 
"Cost crosses sentinel value");
 
  124    return InlineCost(Cost, Threshold, StaticBonus);
 
 
  128            std::optional<CostBenefitPair> CostBenefit = std::nullopt) {
 
  129    return InlineCost(AlwaysInlineCost, 0, 0, Reason, CostBenefit);
 
 
  133           std::optional<CostBenefitPair> CostBenefit = std::nullopt) {
 
  134    return InlineCost(NeverInlineCost, 0, 0, Reason, CostBenefit);
 
 
  138  explicit operator bool()
 const { 
return Cost < Threshold; }
 
  140  bool isAlways()
 const { 
return Cost == AlwaysInlineCost; }
 
  141  bool isNever()
 const { 
return Cost == NeverInlineCost; }
 
  160    return StaticBonusApplied;
 
 
  169           "InlineCost reason must be set for Always or Never");
 
 
 
  182  const char *Message = 
nullptr;
 
  183  InlineResult(
const char *Message = 
nullptr) : Message(Message) {}
 
  187  static InlineResult 
failure(
const char *Reason) {
 
  188    return InlineResult(Reason);
 
 
  193           "getFailureReason should only be called in failure cases");
 
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
This file implements a class to represent arbitrary precision integral constant values and operations...
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
This header defines various interfaces for pass management in LLVM.
 
FunctionAnalysisManager FAM
 
Class for arbitrary precision integers.
 
A cache of @llvm.assume calls within a function.
 
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
 
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
 
const APInt & getBenefit() const
 
CostBenefitPair(APInt Cost, APInt Benefit)
 
const APInt & getCost() const
 
A parsed version of the target data layout string in and methods for querying it.
 
A cache of ephemeral values within a function.
 
Represents the cost of inlining a function.
 
std::optional< CostBenefitPair > getCostBenefit() const
Get the cost-benefit pair which was computed by cost-benefit analysis.
 
int getThreshold() const
Get the threshold against which the cost was computed.
 
const char * getReason() const
Get the reason of Always or Never.
 
int getStaticBonusApplied() const
Get the amount of StaticBonus applied.
 
int getCost() const
Get the inline cost estimate.
 
static InlineCost getNever(const char *Reason, std::optional< CostBenefitPair > CostBenefit=std::nullopt)
 
static InlineCost getAlways(const char *Reason, std::optional< CostBenefitPair > CostBenefit=std::nullopt)
 
static InlineCost get(int Cost, int Threshold, int StaticBonus=0)
 
int getCostDelta() const
Get the cost delta from the threshold for inlining.
 
InlineResult is basically true or false.
 
static InlineResult success()
 
static InlineResult failure(const char *Reason)
 
const char * getFailureReason() const
 
A set of analyses that are preserved following a run of a transformation pass.
 
Analysis providing profile information.
 
StringRef - Represent a constant reference to a string, i.e.
 
Provides information about what library functions are available for the current target.
 
An efficient, type-erasing, non-owning reference to a callable.
 
This class implements an extremely fast bulk output stream that can only output to a stream.
 
const char FunctionInlineCostMultiplierAttributeName[]
 
const int OptSizeThreshold
Use when optsize (-Os) is specified.
 
const int OptMinSizeThreshold
Use when minsize (-Oz) is specified.
 
const uint64_t MaxSimplifiedDynamicAllocaToInline
Do not inline dynamic allocas that have been constant propagated to be static allocas above this amou...
 
const int IndirectCallThreshold
 
const int OptAggressiveThreshold
Use when -O3 is specified.
 
const char MaxInlineStackSizeAttributeName[]
 
const unsigned TotalAllocaSizeRecursiveCaller
Do not inline functions which allocate this many bytes on the stack when the caller is recursive.
 
LLVM_ABI int getInstrCost()
 
This is an optimization pass for GlobalISel generic memory operations.
 
LLVM_ABI std::optional< int > getStringFnAttrAsInt(CallBase &CB, StringRef AttrKind)
 
LLVM_ABI InlineResult isInlineViable(Function &Callee)
Check if it is mechanically possible to inline the function Callee, based on the contents of the func...
 
LLVM_ABI std::optional< InlineCostFeatures > getInliningCostFeatures(CallBase &Call, TargetTransformInfo &CalleeTTI, function_ref< AssumptionCache &(Function &)> GetAssumptionCache, function_ref< BlockFrequencyInfo &(Function &)> GetBFI=nullptr, function_ref< const TargetLibraryInfo &(Function &)> GetTLI=nullptr, ProfileSummaryInfo *PSI=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Get the expanded cost features.
 
LLVM_ABI 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, function_ref< EphemeralValuesCache &(Function &)> GetEphValuesCache=nullptr)
Get an InlineCost object representing the cost of inlining this callsite.
 
LLVM_ABI std::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,...
 
LLVM_ABI InlineParams getInlineParams()
Generate the parameters to tune the inline cost analysis based only on the commandline options.
 
LLVM_ABI int getCallsiteCost(const TargetTransformInfo &TTI, const CallBase &Call, const DataLayout &DL)
Return the cost associated with a callsite, including parameter passing and the call/return instructi...
 
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
 
LLVM_ABI std::optional< int > getInliningCostEstimate(CallBase &Call, TargetTransformInfo &CalleeTTI, function_ref< AssumptionCache &(Function &)> GetAssumptionCache, function_ref< BlockFrequencyInfo &(Function &)> GetBFI=nullptr, function_ref< const TargetLibraryInfo &(Function &)> GetTLI=nullptr, ProfileSummaryInfo *PSI=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Get the cost estimate ignoring thresholds.
 
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
 
Implement std::hash so that hash_code can be used in STL containers.
 
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
 
InlineCostAnnotationPrinterPass(raw_ostream &OS)
 
Thresholds to tune inline cost analysis.
 
std::optional< int > OptMinSizeThreshold
Threshold to use when the caller is optimized for minsize.
 
std::optional< int > OptSizeThreshold
Threshold to use when the caller is optimized for size.
 
std::optional< int > ColdCallSiteThreshold
Threshold to use when the callsite is considered cold.
 
std::optional< int > ColdThreshold
Threshold to use for cold callees.
 
std::optional< int > HotCallSiteThreshold
Threshold to use when the callsite is considered hot.
 
std::optional< bool > AllowRecursiveCall
Indicate whether we allow inlining for recursive call.
 
int DefaultThreshold
The default threshold to start with for a callee.
 
std::optional< bool > EnableDeferral
Indicate whether we should allow inline deferral.
 
std::optional< int > HintThreshold
Threshold to use for callees with inline hint.
 
std::optional< int > LocallyHotCallSiteThreshold
Threshold to use when the callsite is considered hot relative to function entry.
 
std::optional< bool > ComputeFullInlineCost
Compute inline cost even when the cost has exceeded the threshold.
 
A CRTP mix-in to automatically provide informational APIs needed for passes.