LLVM 17.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
 
void refresh ()
 If no summary is present, attempt to refresh.
 
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.
 
std::optional< uint64_tgetProfileCount (const CallBase &CallInst, BlockFrequencyInfo *BFI, bool AllowSynthetic=false) const
 Returns the profile count for CallInst.
 
bool hasPartialSampleProfile () const
 Returns true if module M has partial-profile sample profile.
 
bool hasHugeWorkingSetSize () const
 Returns true if the working set size of the code is considered huge.
 
bool hasLargeWorkingSetSize () const
 Returns true if the working set size of the code is considered large.
 
bool isFunctionEntryHot (const Function *F) const
 Returns true if F has hot function entry.
 
bool isFunctionHotInCallGraph (const Function *F, BlockFrequencyInfo &BFI) const
 Returns true if F contains hot code.
 
bool isFunctionEntryCold (const Function *F) const
 Returns true if F has cold function entry.
 
bool isFunctionColdInCallGraph (const Function *F, BlockFrequencyInfo &BFI) const
 Returns true if F contains only cold code.
 
bool isFunctionHotnessUnknown (const Function &F) const
 Returns true if the hotness of F is unknown.
 
bool isFunctionHotInCallGraphNthPercentile (int PercentileCutoff, const Function *F, BlockFrequencyInfo &BFI) const
 Returns true if F contains hot code with regard to a given hot percentile cutoff value.
 
bool isFunctionColdInCallGraphNthPercentile (int PercentileCutoff, const Function *F, BlockFrequencyInfo &BFI) const
 Returns true if F contains cold code with regard to a given cold percentile cutoff value.
 
bool isHotCount (uint64_t C) const
 Returns true if count C is considered hot.
 
bool isColdCount (uint64_t C) const
 Returns true if count C is considered cold.
 
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.
 
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.
 
bool isHotBlock (const BasicBlock *BB, BlockFrequencyInfo *BFI) const
 Returns true if BasicBlock BB is considered hot.
 
bool isColdBlock (const BasicBlock *BB, BlockFrequencyInfo *BFI) const
 Returns true if BasicBlock BB is considered cold.
 
bool isHotBlockNthPercentile (int PercentileCutoff, const BasicBlock *BB, BlockFrequencyInfo *BFI) const
 Returns true if BasicBlock BB is considered hot with regard to a given hot percentile cutoff value.
 
bool isColdBlockNthPercentile (int PercentileCutoff, const BasicBlock *BB, BlockFrequencyInfo *BFI) const
 Returns true if BasicBlock BB is considered cold with regard to a given cold percentile cutoff value.
 
bool isHotCallSite (const CallBase &CB, BlockFrequencyInfo *BFI) const
 Returns true if the call site CB is considered hot.
 
bool isColdCallSite (const CallBase &CB, BlockFrequencyInfo *BFI) const
 Returns true if call site CB is considered cold.
 
uint64_t getOrCompHotCountThreshold () const
 Returns HotCountThreshold if set.
 
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 40 of file ProfileSummaryInfo.h.

Constructor & Destructor Documentation

◆ ProfileSummaryInfo() [1/2]

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

Definition at line 62 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 177 of file ProfileSummaryInfo.h.

◆ getHotCountThreshold()

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

Returns HotCountThreshold if set.

Definition at line 173 of file ProfileSummaryInfo.h.

◆ getOrCompColdCountThreshold()

uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold ( ) const

Returns ColdCountThreshold if set.

Recompute HotCountThreshold if not set.

Definition at line 324 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 320 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

◆ hasCSInstrumentationProfile()

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

Returns true if module M has context sensitive instrumentation profile.

Definition at line 84 of file ProfileSummaryInfo.h.

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

◆ hasHugeWorkingSetSize()

bool ProfileSummaryInfo::hasHugeWorkingSetSize ( ) const

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

Definition at line 284 of file ProfileSummaryInfo.cpp.

◆ hasInstrumentationProfile()

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

Returns true if module M has instrumentation profile.

Definition at line 78 of file ProfileSummaryInfo.h.

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

Referenced by llvm::isPGSOColdCodeOnly().

◆ hasLargeWorkingSetSize()

bool ProfileSummaryInfo::hasLargeWorkingSetSize ( ) const

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

Definition at line 288 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 377 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 95 of file ProfileSummaryInfo.h.

◆ isColdBlock()

bool ProfileSummaryInfo::isColdBlock ( const BasicBlock BB,
BlockFrequencyInfo BFI 
) const

Returns true if BasicBlock BB is considered cold.

Definition at line 334 of file ProfileSummaryInfo.cpp.

References isColdCount().

Referenced by isFunctionColdInCallGraph(), and unswitchLoop().

◆ isColdBlockNthPercentile()

bool ProfileSummaryInfo::isColdBlockNthPercentile ( int  PercentileCutoff,
const BasicBlock BB,
BlockFrequencyInfo BFI 
) const

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 355 of file ProfileSummaryInfo.cpp.

References PercentileCutoff.

◆ isColdCallSite()

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

Returns true if call site CB is considered cold.

Definition at line 366 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

Returns true if count C is considered cold.

Definition at line 296 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C.

Referenced by llvm::sampleprofutil::callsiteIsHot(), getHotness(), isColdBlock(), isColdCallSite(), isFunctionColdInCallGraph(), and isFunctionEntryCold().

◆ 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 315 of file ProfileSummaryInfo.cpp.

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

Referenced by isColdBlock().

◆ isFunctionColdInCallGraph()

bool ProfileSummaryInfo::isFunctionColdInCallGraph ( const Function F,
BlockFrequencyInfo BFI 
) const

Returns true if F contains only cold code.

Returns true if the function only contains cold code.

This means that the function entry and blocks are all cold, and (in the case of Sample PGO) the total call edge count is cold. If it returns false, it either means it is not cold or it is unknown (for example, no profile data is available).

Definition at line 145 of file ProfileSummaryInfo.cpp.

References F, getProfileCount(), hasProfileSummary(), hasSampleProfile(), I, isColdBlock(), and isColdCount().

◆ isFunctionColdInCallGraphNthPercentile()

bool ProfileSummaryInfo::isFunctionColdInCallGraphNthPercentile ( int  PercentileCutoff,
const Function F,
BlockFrequencyInfo BFI 
) const

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

Definition at line 215 of file ProfileSummaryInfo.cpp.

References F, and PercentileCutoff.

◆ 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 224 of file ProfileSummaryInfo.cpp.

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

Referenced by llvm::ProfileSummaryPrinterPass::run().

◆ isFunctionEntryHot()

bool ProfileSummaryInfo::isFunctionEntryHot ( const Function F) const

Returns true if F has hot function entry.

Returns true if the function's entry is hot.

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 101 of file ProfileSummaryInfo.cpp.

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

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

◆ isFunctionHotInCallGraph()

bool ProfileSummaryInfo::isFunctionHotInCallGraph ( const Function F,
BlockFrequencyInfo BFI 
) const

Returns true if F contains hot code.

Returns true if the function contains hot code.

This can include a hot function entry count, hot basic block, or (in the case of Sample PGO) hot total call edge count. If it returns false, it either means it is not hot or it is unknown (for example, no profile data is available).

Definition at line 116 of file ProfileSummaryInfo.cpp.

References F, getProfileCount(), hasProfileSummary(), hasSampleProfile(), I, isHotBlock(), and isHotCount().

◆ isFunctionHotInCallGraphNthPercentile()

bool ProfileSummaryInfo::isFunctionHotInCallGraphNthPercentile ( int  PercentileCutoff,
const Function F,
BlockFrequencyInfo BFI 
) const

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

Definition at line 209 of file ProfileSummaryInfo.cpp.

References F, and PercentileCutoff.

◆ isFunctionHotnessUnknown()

bool ProfileSummaryInfo::isFunctionHotnessUnknown ( const Function F) const

Returns true if the hotness of F is unknown.

Definition at line 169 of file ProfileSummaryInfo.cpp.

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

◆ isHotBlock()

bool ProfileSummaryInfo::isHotBlock ( const BasicBlock BB,
BlockFrequencyInfo BFI 
) const

Returns true if BasicBlock BB is considered hot.

Definition at line 328 of file ProfileSummaryInfo.cpp.

References isHotCount().

Referenced by isFunctionHotInCallGraph().

◆ isHotBlockNthPercentile()

bool ProfileSummaryInfo::isHotBlockNthPercentile ( int  PercentileCutoff,
const BasicBlock BB,
BlockFrequencyInfo BFI 
) const

Returns true if BasicBlock BB 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 350 of file ProfileSummaryInfo.cpp.

References PercentileCutoff.

◆ isHotCallSite()

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

Returns true if the call site CB is considered hot.

Definition at line 360 of file ProfileSummaryInfo.cpp.

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

◆ isHotCount()

bool ProfileSummaryInfo::isHotCount ( uint64_t  C) const

Returns true if count C is considered hot.

Definition at line 292 of file ProfileSummaryInfo.cpp.

References llvm::CallingConv::C.

Referenced by llvm::sampleprofutil::callsiteIsHot(), getHotness(), isFunctionEntryHot(), isFunctionHotInCallGraph(), isHotBlock(), and isHotCallSite().

◆ 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 310 of file ProfileSummaryInfo.cpp.

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

◆ refresh()

void ProfileSummaryInfo::refresh ( )

If no summary is present, attempt to refresh.

Definition at line 60 of file ProfileSummaryInfo.cpp.

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

Referenced by annotateAllFunctions(), and ProfileSummaryInfo().


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