LLVM  16.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::InlineCost Class Reference

Represents the cost of inlining a function. More...

#include "llvm/Analysis/InlineCost.h"

Public Member Functions

 operator bool () const
 Test whether the inline cost is low enough for inlining. More...
 
bool isAlways () const
 
bool isNever () const
 
bool isVariable () const
 
int getCost () const
 Get the inline cost estimate. More...
 
int getThreshold () const
 Get the threshold against which the cost was computed. More...
 
int getStaticBonusApplied () const
 Get the amount of StaticBonus applied. More...
 
Optional< CostBenefitPairgetCostBenefit () const
 Get the cost-benefit pair which was computed by cost-benefit analysis. More...
 
const char * getReason () const
 Get the reason of Always or Never. More...
 
int getCostDelta () const
 Get the cost delta from the threshold for inlining. More...
 

Static Public Member Functions

static InlineCost get (int Cost, int Threshold, int StaticBonus=0)
 
static InlineCost getAlways (const char *Reason, Optional< CostBenefitPair > CostBenefit=None)
 
static InlineCost getNever (const char *Reason, Optional< CostBenefitPair > CostBenefit=None)
 

Detailed 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.

Definition at line 89 of file InlineCost.h.

Member Function Documentation

◆ get()

static InlineCost llvm::InlineCost::get ( int  Cost,
int  Threshold,
int  StaticBonus = 0 
)
inlinestatic

Definition at line 119 of file InlineCost.h.

References assert(), and Cost.

Referenced by llvm::getInlineCost().

◆ getAlways()

static InlineCost llvm::InlineCost::getAlways ( const char *  Reason,
Optional< CostBenefitPair CostBenefit = None 
)
inlinestatic

◆ getCost()

int llvm::InlineCost::getCost ( ) const
inline

Get the inline cost estimate.

It is an error to call this on an "always" or "never" InlineCost.

Definition at line 142 of file InlineCost.h.

References assert(), Cost, and isVariable().

Referenced by getCostDelta(), llvm::operator<<(), shouldBeDeferred(), and llvm::shouldInline().

◆ getCostBenefit()

Optional<CostBenefitPair> llvm::InlineCost::getCostBenefit ( ) const
inline

Get the cost-benefit pair which was computed by cost-benefit analysis.

Definition at line 160 of file InlineCost.h.

References CostBenefit.

◆ getCostDelta()

int llvm::InlineCost::getCostDelta ( ) const
inline

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.

Definition at line 172 of file InlineCost.h.

References getCost().

Referenced by shouldBeDeferred().

◆ getNever()

static InlineCost llvm::InlineCost::getNever ( const char *  Reason,
Optional< CostBenefitPair CostBenefit = None 
)
inlinestatic

Definition at line 128 of file InlineCost.h.

References CostBenefit.

Referenced by llvm::getInlineCost().

◆ getReason()

const char* llvm::InlineCost::getReason ( ) const
inline

Get the reason of Always or Never.

Definition at line 163 of file InlineCost.h.

References assert(), and isVariable().

Referenced by llvm::operator<<().

◆ getStaticBonusApplied()

int llvm::InlineCost::getStaticBonusApplied ( ) const
inline

Get the amount of StaticBonus applied.

Definition at line 154 of file InlineCost.h.

References assert(), and isVariable().

◆ getThreshold()

int llvm::InlineCost::getThreshold ( ) const
inline

Get the threshold against which the cost was computed.

Definition at line 148 of file InlineCost.h.

References assert(), and isVariable().

Referenced by llvm::operator<<().

◆ isAlways()

bool llvm::InlineCost::isAlways ( ) const
inline

◆ isNever()

bool llvm::InlineCost::isNever ( ) const
inline

Definition at line 137 of file InlineCost.h.

References Cost.

Referenced by isVariable(), llvm::operator<<(), and llvm::shouldInline().

◆ isVariable()

bool llvm::InlineCost::isVariable ( ) const
inline

Definition at line 138 of file InlineCost.h.

References isAlways(), and isNever().

Referenced by getCost(), getReason(), getStaticBonusApplied(), and getThreshold().

◆ operator bool()

llvm::InlineCost::operator bool ( ) const
inlineexplicit

Test whether the inline cost is low enough for inlining.

Definition at line 134 of file InlineCost.h.

References Cost.


The documentation for this class was generated from the following file: