class InlineCost
Declaration
class InlineCost { /* full declaration omitted */ };
Description
Represents the cost of inlining a function. This supports special values for functions which should "always" or "never" be inlined. Otherwise, the cost represents a unitless amount; smaller values increase the likelihood of the function being inlined. Objects of this type also provide the adjusted threshold for inlining based on the information available for a particular callsite. They can be directly tested to determine if inlining should occur given the cost and threshold for this cost metric.
Declared at: llvm/include/llvm/Analysis/InlineCost.h:87
Member Variables
- private int Cost = 0
- The estimated cost of inlining this callsite.
- private int Threshold = 0
- The adjusted threshold against which this cost was computed.
- private const char* Reason = nullptr
- Must be set for Always and Never instances.
- private Optional<llvm::CostBenefitPair> CostBenefit = None
- The cost-benefit pair computed by cost-benefit analysis.
Method Overview
- private InlineCost(int Cost, int Threshold, const char * Reason = nullptr, Optional<llvm::CostBenefitPair> CostBenefit = None)
- public static llvm::InlineCost get(int Cost, int Threshold)
- public static llvm::InlineCost getAlways(const char * Reason, Optional<llvm::CostBenefitPair> CostBenefit = None)
- public int getCost() const
- public Optional<llvm::CostBenefitPair> getCostBenefit() const
- public int getCostDelta() const
- public static llvm::InlineCost getNever(const char * Reason, Optional<llvm::CostBenefitPair> CostBenefit = None)
- public const char * getReason() const
- public int getThreshold() const
- public bool isAlways() const
- public bool isNever() const
- public bool isVariable() const
- public bool operator bool() const
Methods
¶InlineCost(int Cost,
int Threshold,
const char* Reason = nullptr,
Optional<llvm::CostBenefitPair>
CostBenefit = None)
InlineCost(int Cost,
int Threshold,
const char* Reason = nullptr,
Optional<llvm::CostBenefitPair>
CostBenefit = None)
Declared at: llvm/include/llvm/Analysis/InlineCost.h:103
Parameters
- int Cost
- int Threshold
- const char* Reason = nullptr
- Optional<llvm::CostBenefitPair> CostBenefit = None
¶static llvm::InlineCost get(int Cost,
int Threshold)
static llvm::InlineCost get(int Cost,
int Threshold)
Declared at: llvm/include/llvm/Analysis/InlineCost.h:112
Parameters
- int Cost
- int Threshold
¶static llvm::InlineCost getAlways(
const char* Reason,
Optional<llvm::CostBenefitPair> CostBenefit =
None)
static llvm::InlineCost getAlways(
const char* Reason,
Optional<llvm::CostBenefitPair> CostBenefit =
None)
Declared at: llvm/include/llvm/Analysis/InlineCost.h:117
Parameters
- const char* Reason
- Optional<llvm::CostBenefitPair> CostBenefit = None
¶int getCost() const
int getCost() const
Description
Get the inline cost estimate. It is an error to call this on an "always" or "never" InlineCost.
Declared at: llvm/include/llvm/Analysis/InlineCost.h:135
¶Optional<llvm::CostBenefitPair> getCostBenefit()
const
Optional<llvm::CostBenefitPair> getCostBenefit()
const
Description
Get the cost-benefit pair which was computed by cost-benefit analysis
Declared at: llvm/include/llvm/Analysis/InlineCost.h:147
¶int getCostDelta() const
int getCostDelta() const
Description
Get the cost delta from the threshold for inlining. Only valid if the cost is of the variable kind. Returns a negative value if the cost is too high to inline.
Declared at: llvm/include/llvm/Analysis/InlineCost.h:159
¶static llvm::InlineCost getNever(
const char* Reason,
Optional<llvm::CostBenefitPair> CostBenefit =
None)
static llvm::InlineCost getNever(
const char* Reason,
Optional<llvm::CostBenefitPair> CostBenefit =
None)
Declared at: llvm/include/llvm/Analysis/InlineCost.h:121
Parameters
- const char* Reason
- Optional<llvm::CostBenefitPair> CostBenefit = None
¶const char* getReason() const
const char* getReason() const
Description
Get the reason of Always or Never.
Declared at: llvm/include/llvm/Analysis/InlineCost.h:150
¶int getThreshold() const
int getThreshold() const
Description
Get the threshold against which the cost was computed
Declared at: llvm/include/llvm/Analysis/InlineCost.h:141
¶bool isAlways() const
bool isAlways() const
Declared at: llvm/include/llvm/Analysis/InlineCost.h:129
¶bool isNever() const
bool isNever() const
Declared at: llvm/include/llvm/Analysis/InlineCost.h:130
¶bool isVariable() const
bool isVariable() const
Declared at: llvm/include/llvm/Analysis/InlineCost.h:131
¶bool operator bool() const
bool operator bool() const
Description
Test whether the inline cost is low enough for inlining.
Declared at: llvm/include/llvm/Analysis/InlineCost.h:127