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

BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequencies. More...

#include "llvm/Analysis/BlockFrequencyInfo.h"

Public Member Functions

LLVM_ABI BlockFrequencyInfo ()
 
LLVM_ABI BlockFrequencyInfo (const Function &F, const BranchProbabilityInfo &BPI, const LoopInfo &LI)
 
 BlockFrequencyInfo (const BlockFrequencyInfo &)=delete
 
BlockFrequencyInfooperator= (const BlockFrequencyInfo &)=delete
 
LLVM_ABI BlockFrequencyInfo (BlockFrequencyInfo &&Arg)
 
LLVM_ABI BlockFrequencyInfooperator= (BlockFrequencyInfo &&RHS)
 
LLVM_ABI ~BlockFrequencyInfo ()
 
LLVM_ABI bool invalidate (Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
 Handle invalidation explicitly.
 
LLVM_ABI const FunctiongetFunction () const
 
LLVM_ABI const BranchProbabilityInfogetBPI () const
 
LLVM_ABI void view (StringRef="BlockFrequencyDAGs") const
 Pop up a ghostview window with the current block frequency propagation rendered using dot.
 
LLVM_ABI BlockFrequency getBlockFreq (const BasicBlock *BB) const
 getblockFreq - Return block frequency.
 
LLVM_ABI std::optional< uint64_tgetBlockProfileCount (const BasicBlock *BB, bool AllowSynthetic=false) const
 Returns the estimated profile count of BB.
 
LLVM_ABI std::optional< uint64_tgetProfileCountFromFreq (BlockFrequency Freq) const
 Returns the estimated profile count of Freq.
 
LLVM_ABI bool isIrrLoopHeader (const BasicBlock *BB)
 Returns true if BB is an irreducible loop header block.
 
LLVM_ABI void setBlockFreq (const BasicBlock *BB, BlockFrequency Freq)
 
LLVM_ABI void setBlockFreqAndScale (const BasicBlock *ReferenceBB, BlockFrequency Freq, SmallPtrSetImpl< BasicBlock * > &BlocksToScale)
 Set the frequency of ReferenceBB to Freq and scale the frequencies of the blocks in BlocksToScale such that their frequencies relative to ReferenceBB remain unchanged.
 
LLVM_ABI void calculate (const Function &F, const BranchProbabilityInfo &BPI, const LoopInfo &LI)
 calculate - compute block frequency info for the given function.
 
LLVM_ABI BlockFrequency getEntryFreq () const
 
LLVM_ABI void releaseMemory ()
 
LLVM_ABI void print (raw_ostream &OS) const
 
LLVM_ABI void verifyMatch (BlockFrequencyInfo &Other) const
 

Detailed Description

BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequencies.

Definition at line 38 of file BlockFrequencyInfo.h.

Constructor & Destructor Documentation

◆ BlockFrequencyInfo() [1/4]

BlockFrequencyInfo::BlockFrequencyInfo ( )
default

◆ BlockFrequencyInfo() [2/4]

BlockFrequencyInfo::BlockFrequencyInfo ( const Function F,
const BranchProbabilityInfo BPI,
const LoopInfo LI 
)

Definition at line 154 of file BlockFrequencyInfo.cpp.

References calculate(), and F.

◆ BlockFrequencyInfo() [3/4]

llvm::BlockFrequencyInfo::BlockFrequencyInfo ( const BlockFrequencyInfo )
delete

◆ BlockFrequencyInfo() [4/4]

BlockFrequencyInfo::BlockFrequencyInfo ( BlockFrequencyInfo &&  Arg)

Definition at line 160 of file BlockFrequencyInfo.cpp.

◆ ~BlockFrequencyInfo()

BlockFrequencyInfo::~BlockFrequencyInfo ( )
default

Member Function Documentation

◆ calculate()

void BlockFrequencyInfo::calculate ( const Function F,
const BranchProbabilityInfo BPI,
const LoopInfo LI 
)

◆ getBlockFreq()

BlockFrequency BlockFrequencyInfo::getBlockFreq ( const BasicBlock BB) const

getblockFreq - Return block frequency.

Return 0 if we don't have the information. Please note that initial frequency is equal to ENTRY_FREQ. It means that we should not rely on the value itself, but only on the comparison to the other block frequencies. We do this to avoid using of floating points.

Definition at line 200 of file BlockFrequencyInfo.cpp.

Referenced by llvm::CodeExtractor::extractCodeRegion(), llvm::InlineFunctionImpl(), isColdCallSite(), llvm::JumpThreadingPass::threadEdge(), llvm::JumpThreadingPass::threadThroughTwoBasicBlocks(), and updateCallerBFI().

◆ getBlockProfileCount()

std::optional< uint64_t > BlockFrequencyInfo::getBlockProfileCount ( const BasicBlock BB,
bool  AllowSynthetic = false 
) const

Returns the estimated profile count of BB.

This computes the relative block frequency of BB and multiplies it by the enclosing function's count (if available) and returns the value.

Definition at line 205 of file BlockFrequencyInfo.cpp.

References getFunction().

Referenced by fixFuncEntryCount(), and verifyFuncBFI().

◆ getBPI()

const BranchProbabilityInfo * BlockFrequencyInfo::getBPI ( ) const

Definition at line 263 of file BlockFrequencyInfo.cpp.

◆ getEntryFreq()

BlockFrequency BlockFrequencyInfo::getEntryFreq ( ) const

Definition at line 267 of file BlockFrequencyInfo.cpp.

◆ getFunction()

const Function * BlockFrequencyInfo::getFunction ( ) const

Definition at line 259 of file BlockFrequencyInfo.cpp.

Referenced by getBlockProfileCount(), and getProfileCountFromFreq().

◆ getProfileCountFromFreq()

std::optional< uint64_t > BlockFrequencyInfo::getProfileCountFromFreq ( BlockFrequency  Freq) const

Returns the estimated profile count of Freq.

This uses the frequency Freq and multiplies it by the enclosing function's count (if available) and returns the value.

Definition at line 214 of file BlockFrequencyInfo.cpp.

References getFunction().

◆ invalidate()

bool BlockFrequencyInfo::invalidate ( Function F,
const PreservedAnalyses PA,
FunctionAnalysisManager::Invalidator  
)

Handle invalidation explicitly.

Definition at line 175 of file BlockFrequencyInfo.cpp.

References llvm::PreservedAnalyses::getChecker().

◆ isIrrLoopHeader()

bool BlockFrequencyInfo::isIrrLoopHeader ( const BasicBlock BB)

Returns true if BB is an irreducible loop header block.

Otherwise false.

Definition at line 220 of file BlockFrequencyInfo.cpp.

References assert().

◆ operator=() [1/2]

BlockFrequencyInfo & BlockFrequencyInfo::operator= ( BlockFrequencyInfo &&  RHS)

Definition at line 163 of file BlockFrequencyInfo.cpp.

References releaseMemory(), and RHS.

◆ operator=() [2/2]

BlockFrequencyInfo & llvm::BlockFrequencyInfo::operator= ( const BlockFrequencyInfo )
delete

◆ print()

void BlockFrequencyInfo::print ( raw_ostream OS) const

Definition at line 273 of file BlockFrequencyInfo.cpp.

References OS.

Referenced by calculate(), and llvm::BlockFrequencyInfoWrapperPass::print().

◆ releaseMemory()

void BlockFrequencyInfo::releaseMemory ( )

◆ setBlockFreq()

void BlockFrequencyInfo::setBlockFreq ( const BasicBlock BB,
BlockFrequency  Freq 
)

◆ setBlockFreqAndScale()

void BlockFrequencyInfo::setBlockFreqAndScale ( const BasicBlock ReferenceBB,
BlockFrequency  Freq,
SmallPtrSetImpl< BasicBlock * > &  BlocksToScale 
)

Set the frequency of ReferenceBB to Freq and scale the frequencies of the blocks in BlocksToScale such that their frequencies relative to ReferenceBB remain unchanged.

Definition at line 231 of file BlockFrequencyInfo.cpp.

References assert(), BBFreq, and llvm::BlockFrequency::getFrequency().

Referenced by updateCallerBFI().

◆ verifyMatch()

void BlockFrequencyInfo::verifyMatch ( BlockFrequencyInfo Other) const

Definition at line 278 of file BlockFrequencyInfo.cpp.

References llvm::Other.

◆ view()

void BlockFrequencyInfo::view ( StringRef  title = "BlockFrequencyDAGs") const

Pop up a ghostview window with the current block frequency propagation rendered using dot.

Definition at line 255 of file BlockFrequencyInfo.cpp.

References llvm::ViewGraph().

Referenced by calculate().


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