LLVM 22.0.0git
Public Member Functions | List of all members
llvm::ProfileSummaryInfo Class Reference

Analysis providing profile information. More...

#include "llvm/Analysis/ProfileSummaryInfo.h"

Public Member Functions

 ProfileSummaryInfo (const Module &M)
 
 ProfileSummaryInfo (ProfileSummaryInfo &&Arg)=default
 
LLVM_ABI void refresh (std::unique_ptr< ProfileSummary > &&Other=nullptr)
 If a summary is provided as argument, use that.
 
bool hasProfileSummary () const
 Returns true if profile summary is available.
 
bool hasSampleProfile () const
 Returns true if module M has sample profile.
 
bool hasInstrumentationProfile () const
 Returns true if module M has instrumentation profile.
 
bool hasCSInstrumentationProfile () const
 Returns true if module M has context sensitive instrumentation profile.
 
bool invalidate (Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &)
 Handle the invalidation of this information.
 
LLVM_ABI std::optional< uint64_tgetProfileCount (const CallBase &CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false) const
 Returns the profile count for CallInst.
 
LLVM_ABI bool hasPartialSampleProfile () const
 Returns true if module M has partial-profile sample profile.
 
LLVM_ABI bool hasHugeWorkingSetSize () const
 Returns true if the working set size of the code is considered huge.
 
LLVM_ABI bool hasLargeWorkingSetSize () const
 Returns true if the working set size of the code is considered large.
 
template<typename FuncT >
bool isFunctionEntryHot (const FuncT *F) const
 Returns true if F has hot function entry.
 
template<typename FuncT , typename BFIT >
bool isFunctionHotInCallGraph (const FuncT *F, BFIT &BFI) const
 Returns true if F contains hot code.
 
LLVM_ABI bool isFunctionEntryCold (const Function *F) const
 Returns true if F has cold function entry.
 
template<typename FuncT , typename BFIT >
bool isFunctionColdInCallGraph (const FuncT *F, BFIT &BFI) const
 Returns true if F contains only cold code.
 
LLVM_ABI bool isFunctionHotnessUnknown (const Function &F) const
 Returns true if the hotness of F is unknown.
 
template<typename FuncT , typename BFIT >
bool isFunctionHotInCallGraphNthPercentile (int PercentileCutoff, const FuncT *F, BFIT &BFI) const
 Returns true if F contains hot code with regard to a given hot percentile cutoff value.
 
template<typename FuncT , typename BFIT >
bool isFunctionColdInCallGraphNthPercentile (int PercentileCutoff, const FuncT *F, BFIT &BFI) const
 Returns true if F contains cold code with regard to a given cold percentile cutoff value.
 
LLVM_ABI bool isHotCount (uint64_t C) const
 Returns true if count C is considered hot.
 
LLVM_ABI bool isColdCount (uint64_t C) const
 Returns true if count C is considered cold.
 
LLVM_ABI bool isHotCountNthPercentile (int PercentileCutoff, uint64_t C) const
 Returns true if count C is considered hot with regard to a given hot percentile cutoff value.
 
LLVM_ABI bool isColdCountNthPercentile (int PercentileCutoff, uint64_t C) const
 Returns true if count C is considered cold with regard to a given cold percentile cutoff value.
 
template<typename BBType , typename BFIT >
bool isHotBlock (const BBType *BB, BFIT *BFI) const
 Returns true if BasicBlock BB is considered hot.
 
template<typename BBType , typename BFIT >
bool isColdBlock (const BBType *BB, BFIT *BFI) const
 Returns true if BasicBlock BB is considered cold.
 
template<typename BFIT >
bool isColdBlock (BlockFrequency BlockFreq, const BFIT *BFI) const
 
template<typename BBType , typename BFIT >
bool isHotBlockNthPercentile (int PercentileCutoff, const BBType *BB, BFIT *BFI) const
 
template<typename BFIT >
bool isHotBlockNthPercentile (int PercentileCutoff, BlockFrequency BlockFreq, BFIT *BFI) const
 
template<typename BBType , typename BFIT >
bool isColdBlockNthPercentile (int PercentileCutoff, const BBType *BB, BFIT *BFI) const
 Returns true if BasicBlock BB is considered cold with regard to a given cold percentile cutoff value.
 
template<typename BFIT >
bool isColdBlockNthPercentile (int PercentileCutoff, BlockFrequency BlockFreq, BFIT *BFI) const
 
LLVM_ABI bool isHotCallSite (const CallBase &CB, BlockFrequencyInfo *BFI) const
 Returns true if the call site CB is considered hot.
 
LLVM_ABI bool isColdCallSite (const CallBase &CB, BlockFrequencyInfo *BFI) const
 Returns true if call site CB is considered cold.
 
LLVM_ABI uint64_t getOrCompHotCountThreshold () const
 Returns HotCountThreshold if set.
 
LLVM_ABI uint64_t getOrCompColdCountThreshold () const
 Returns ColdCountThreshold if set.
 
uint64_t getHotCountThreshold () const
 Returns HotCountThreshold if set.
 
uint64_t getColdCountThreshold () const
 Returns ColdCountThreshold if set.
 

Detailed Description

Analysis providing profile information.

This is an immutable analysis pass that provides ability to query global (program-level) profile information. The main APIs are isHotCount and isColdCount that tells whether a given profile count is considered hot/cold based on the profile summary. This also provides convenience methods to check whether a function is hot or cold.

Definition at line 42 of file ProfileSummaryInfo.h.

Constructor & Destructor Documentation

◆ ProfileSummaryInfo() [1/2]

llvm::ProfileSummaryInfo::ProfileSummaryInfo ( const Module M)
inline

Definition at line 64 of file ProfileSummaryInfo.h.

References refresh().

◆ ProfileSummaryInfo() [2/2]

llvm::ProfileSummaryInfo::ProfileSummaryInfo ( ProfileSummaryInfo &&  Arg)
default

Member Function Documentation

◆ getColdCountThreshold()

uint64_t llvm::ProfileSummaryInfo::getColdCountThreshold ( ) const
inline

Returns ColdCountThreshold if set.

Definition at line 265 of file ProfileSummaryInfo.h.

◆ getHotCountThreshold()

uint64_t llvm::ProfileSummaryInfo::getHotCountThreshold ( ) const
inline

Returns HotCountThreshold if set.

Definition at line 261 of file ProfileSummaryInfo.h.

◆ getOrCompColdCountThreshold()

uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold ( ) const

Returns ColdCountThreshold if set.

Recompute HotCountThreshold if not set.

Definition at line 210 of file ProfileSummaryInfo.cpp.

Referenced by annotateAllFunctions().

◆ getOrCompHotCountThreshold()

uint64_t ProfileSummaryInfo::getOrCompHotCountThreshold ( ) const

Returns HotCountThreshold if set.

Recompute HotCountThreshold if not set.

Definition at line 206 of file ProfileSummaryInfo.cpp.

References UINT64_MAX.

Referenced by annotateAllFunctions().

◆ getProfileCount()

std::optional< uint64_t > ProfileSummaryInfo::getProfileCount ( const CallBase CallInst,
BlockFrequencyInfo BFI,
bool  AllowSynthetic = false 
) const

Returns the profile count for CallInst.

Definition at line 74 of file ProfileSummaryInfo.cpp.

References assert(), and hasSampleProfile().

Referenced by computeFunctionSummary(), isColdCallSite(), isHotCallSite(), and updateCallProfile().

◆ hasCSInstrumentationProfile()

bool llvm::ProfileSummaryInfo::hasCSInstrumentationProfile ( ) const
inline

Returns true if module M has context sensitive instrumentation profile.

Definition at line 87 of file ProfileSummaryInfo.h.

References hasProfileSummary(), and llvm::ProfileSummary::PSK_CSInstr.

Referenced by isColdBlock().

◆ hasHugeWorkingSetSize()

bool ProfileSummaryInfo::hasHugeWorkingSetSize ( ) const

Returns true if the working set size of the code is considered huge.

Definition at line 170 of file ProfileSummaryInfo.cpp.

◆ hasInstrumentationProfile()

bool llvm::ProfileSummaryInfo::hasInstrumentationProfile ( ) const
inline

Returns true if module M has instrumentation profile.

Definition at line 81 of file ProfileSummaryInfo.h.

References hasProfileSummary(), and llvm::ProfileSummary::PSK_Instr.

Referenced by isColdBlock(), and llvm::isPGSOColdCodeOnly().

◆ hasLargeWorkingSetSize()

bool ProfileSummaryInfo::hasLargeWorkingSetSize ( ) const

Returns true if the working set size of the code is considered large.

Definition at line 174 of file ProfileSummaryInfo.cpp.

Referenced by llvm::isPGSOColdCodeOnly().

◆ hasPartialSampleProfile()

bool ProfileSummaryInfo::hasPartialSampleProfile ( ) const

Returns true if module M has partial-profile sample profile.

Definition at line 231 of file ProfileSummaryInfo.cpp.

References hasProfileSummary(), PartialProfile, and llvm::ProfileSummary::PSK_Sample.

Referenced by computeFunctionSummary(), isFunctionHotnessUnknown(), and llvm::isPGSOColdCodeOnly().

◆ hasProfileSummary()

bool llvm::ProfileSummaryInfo::hasProfileSummary ( ) const
inline

◆ hasSampleProfile()

bool llvm::ProfileSummaryInfo::hasSampleProfile ( ) const
inline

◆ invalidate()

bool llvm::ProfileSummaryInfo::invalidate ( Module ,
const PreservedAnalyses ,
ModuleAnalysisManager::Invalidator  
)
inline

Handle the invalidation of this information.

When used as a result of ProfileSummaryAnalysis this method will be called when the module this was computed for changes. Since profile summary is immutable after it is annotated on the module, we return false here.

Definition at line 98 of file ProfileSummaryInfo.h.

◆ isColdBlock() [1/2]

template<typename BFIT >
bool llvm::ProfileSummaryInfo::isColdBlock ( BlockFrequency  BlockFreq,
const BFIT *  BFI 
) const
inline

Definition at line 213 of file ProfileSummaryInfo.h.

References isColdCount().

◆ isColdBlock() [2/2]

template<typename BBType , typename BFIT >
bool llvm::ProfileSummaryInfo::isColdBlock ( const BBType *  BB,
BFIT *  BFI 
) const
inline

Returns true if BasicBlock BB is considered cold.

Definition at line 207 of file ProfileSummaryInfo.h.

References isColdCount().

Referenced by isFunctionColdInCallGraph(), llvm::shouldOptimizeForSizeImpl(), and unswitchLoop().

◆ isColdBlockNthPercentile() [1/2]

template<typename BFIT >
bool llvm::ProfileSummaryInfo::isColdBlockNthPercentile ( int  PercentileCutoff,
BlockFrequency  BlockFreq,
BFIT *  BFI 
) const
inline

Definition at line 243 of file ProfileSummaryInfo.h.

References PercentileCutoff.

◆ isColdBlockNthPercentile() [2/2]

template<typename BBType , typename BFIT >
bool llvm::ProfileSummaryInfo::isColdBlockNthPercentile ( int  PercentileCutoff,
const BBType *  BB,
BFIT *  BFI 
) const
inline

Returns true if BasicBlock BB is considered cold with regard to a given cold percentile cutoff value.

PercentileCutoff is encoded as a 6 digit decimal fixed point number, where the first two digits are the whole part. E.g. 995000 for 99.5 percentile.

Definition at line 237 of file ProfileSummaryInfo.h.

References PercentileCutoff.

Referenced by llvm::shouldOptimizeForSizeImpl().

◆ isColdCallSite()

bool ProfileSummaryInfo::isColdCallSite ( const CallBase CB,
BlockFrequencyInfo BFI 
) const

Returns true if call site CB is considered cold.

Definition at line 220 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C, llvm::CallBase::getCaller(), getProfileCount(), llvm::Function::hasProfileData(), hasSampleProfile(), and isColdCount().

◆ isColdCount()

bool ProfileSummaryInfo::isColdCount ( uint64_t  C) const

◆ isColdCountNthPercentile()

bool ProfileSummaryInfo::isColdCountNthPercentile ( int  PercentileCutoff,
uint64_t  C 
) const

Returns true if count C is considered cold with regard to a given cold percentile cutoff value.

PercentileCutoff is encoded as a 6 digit decimal fixed point number, where the first two digits are the whole part. E.g. 995000 for 99.5 percentile.

Definition at line 201 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C, and PercentileCutoff.

Referenced by isColdBlock().

◆ isFunctionColdInCallGraph()

template<typename FuncT , typename BFIT >
bool llvm::ProfileSummaryInfo::isFunctionColdInCallGraph ( const FuncT *  F,
BFIT &  BFI 
) const
inline

Returns true if F contains only cold code.

Definition at line 148 of file ProfileSummaryInfo.h.

References F, hasProfileSummary(), isColdBlock(), and isColdCount().

Referenced by llvm::shouldFuncOptimizeForSizeImpl(), and shouldRunOnFunction().

◆ isFunctionColdInCallGraphNthPercentile()

template<typename FuncT , typename BFIT >
bool llvm::ProfileSummaryInfo::isFunctionColdInCallGraphNthPercentile ( int  PercentileCutoff,
const FuncT *  F,
BFIT &  BFI 
) const
inline

Returns true if F contains cold code with regard to a given cold percentile cutoff value.

Definition at line 177 of file ProfileSummaryInfo.h.

References F, and PercentileCutoff.

Referenced by llvm::shouldFuncOptimizeForSizeImpl().

◆ isFunctionEntryCold()

bool ProfileSummaryInfo::isFunctionEntryCold ( const Function F) const

Returns true if F has cold function entry.

Returns true if the function's entry is a cold.

If it returns false, it either means it is not cold or it is unknown whether it is cold or not (for example, no profile data is available).

Definition at line 101 of file ProfileSummaryInfo.cpp.

References F, hasProfileSummary(), and isColdCount().

Referenced by llvm::MLInlineAdvisor::getAdviceImpl(), and llvm::ProfileSummaryPrinterPass::run().

◆ isFunctionEntryHot()

template<typename FuncT >
bool llvm::ProfileSummaryInfo::isFunctionEntryHot ( const FuncT *  F) const
inline

Returns true if F has hot function entry.

If it returns false, it either means it is not hot or it is unknown whether it is hot or not (for example, no profile data is available).

Definition at line 116 of file ProfileSummaryInfo.h.

References F, hasProfileSummary(), and isHotCount().

Referenced by llvm::ProfileSummaryPrinterPass::run(), and shouldApply().

◆ isFunctionHotInCallGraph()

template<typename FuncT , typename BFIT >
bool llvm::ProfileSummaryInfo::isFunctionHotInCallGraph ( const FuncT *  F,
BFIT &  BFI 
) const
inline

Returns true if F contains hot code.

Definition at line 128 of file ProfileSummaryInfo.h.

References F, hasProfileSummary(), isHotBlock(), and isHotCount().

◆ isFunctionHotInCallGraphNthPercentile()

template<typename FuncT , typename BFIT >
bool llvm::ProfileSummaryInfo::isFunctionHotInCallGraphNthPercentile ( int  PercentileCutoff,
const FuncT *  F,
BFIT &  BFI 
) const
inline

Returns true if F contains hot code with regard to a given hot percentile cutoff value.

Definition at line 169 of file ProfileSummaryInfo.h.

References F, and PercentileCutoff.

Referenced by llvm::shouldFuncOptimizeForSizeImpl().

◆ isFunctionHotnessUnknown()

bool ProfileSummaryInfo::isFunctionHotnessUnknown ( const Function F) const

Returns true if the hotness of F is unknown.

Definition at line 93 of file ProfileSummaryInfo.cpp.

References assert(), F, and hasPartialSampleProfile().

◆ isHotBlock()

template<typename BBType , typename BFIT >
bool llvm::ProfileSummaryInfo::isHotBlock ( const BBType *  BB,
BFIT *  BFI 
) const
inline

Returns true if BasicBlock BB is considered hot.

Definition at line 200 of file ProfileSummaryInfo.h.

References isHotCount().

Referenced by isFunctionHotInCallGraph().

◆ isHotBlockNthPercentile() [1/2]

template<typename BFIT >
bool llvm::ProfileSummaryInfo::isHotBlockNthPercentile ( int  PercentileCutoff,
BlockFrequency  BlockFreq,
BFIT *  BFI 
) const
inline

Definition at line 226 of file ProfileSummaryInfo.h.

References PercentileCutoff.

◆ isHotBlockNthPercentile() [2/2]

template<typename BBType , typename BFIT >
bool llvm::ProfileSummaryInfo::isHotBlockNthPercentile ( int  PercentileCutoff,
const BBType *  BB,
BFIT *  BFI 
) const
inline

Definition at line 219 of file ProfileSummaryInfo.h.

References PercentileCutoff.

Referenced by llvm::shouldOptimizeForSizeImpl().

◆ isHotCallSite()

bool ProfileSummaryInfo::isHotCallSite ( const CallBase CB,
BlockFrequencyInfo BFI 
) const

Returns true if the call site CB is considered hot.

Definition at line 214 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C, getProfileCount(), and isHotCount().

◆ isHotCount()

bool ProfileSummaryInfo::isHotCount ( uint64_t  C) const

◆ isHotCountNthPercentile()

bool ProfileSummaryInfo::isHotCountNthPercentile ( int  PercentileCutoff,
uint64_t  C 
) const

Returns true if count C is considered hot with regard to a given hot percentile cutoff value.

PercentileCutoff is encoded as a 6 digit decimal fixed point number, where the first two digits are the whole part. E.g. 995000 for 99.5 percentile.

Definition at line 196 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C, and PercentileCutoff.

Referenced by lowerAllowChecks().

◆ refresh()

void ProfileSummaryInfo::refresh ( std::unique_ptr< ProfileSummary > &&  Other = nullptr)

If a summary is provided as argument, use that.

Otherwise, if the Summary member is null, attempt to refresh.

Definition at line 51 of file ProfileSummaryInfo.cpp.

References llvm::ProfileSummary::getFromMD(), llvm::Module::getProfileSummary(), hasProfileSummary(), and llvm::Other.

Referenced by annotateAllFunctions(), and ProfileSummaryInfo().


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