LLVM 19.0.0git
Public Member Functions | List of all members
llvm::MachineBlockFrequencyInfo Class Reference

MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic block frequencies. More...

#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"

Public Member Functions

 MachineBlockFrequencyInfo ()
 
 MachineBlockFrequencyInfo (MachineFunction &F, MachineBranchProbabilityInfo &MBPI, MachineLoopInfo &MLI)
 
 MachineBlockFrequencyInfo (MachineBlockFrequencyInfo &&)
 
 ~MachineBlockFrequencyInfo ()
 
bool invalidate (MachineFunction &F, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &)
 Handle invalidation explicitly.
 
void calculate (const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, const MachineLoopInfo &MLI)
 calculate - compute block frequency info for the given function.
 
void print (raw_ostream &OS)
 
void releaseMemory ()
 
BlockFrequency getBlockFreq (const MachineBasicBlock *MBB) const
 getblockFreq - Return block frequency.
 
double getBlockFreqRelativeToEntryBlock (const MachineBasicBlock *MBB) const
 Compute the frequency of the block, relative to the entry block.
 
std::optional< uint64_tgetBlockProfileCount (const MachineBasicBlock *MBB) const
 
std::optional< uint64_tgetProfileCountFromFreq (BlockFrequency Freq) const
 
bool isIrrLoopHeader (const MachineBasicBlock *MBB) const
 
void onEdgeSplit (const MachineBasicBlock &NewPredecessor, const MachineBasicBlock &NewSuccessor, const MachineBranchProbabilityInfo &MBPI)
 incrementally calculate block frequencies when we split edges, to avoid full CFG traversal.
 
const MachineFunctiongetFunction () const
 
const MachineBranchProbabilityInfogetMBPI () const
 
void view (const Twine &Name, bool isSimple=true) const
 Pop up a ghostview window with the current block frequency propagation rendered using dot.
 
BlockFrequency getEntryFreq () const
 Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relative frequency of said block.
 

Detailed Description

MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic block frequencies.

Definition at line 34 of file MachineBlockFrequencyInfo.h.

Constructor & Destructor Documentation

◆ MachineBlockFrequencyInfo() [1/3]

MachineBlockFrequencyInfo::MachineBlockFrequencyInfo ( )
default

◆ MachineBlockFrequencyInfo() [2/3]

MachineBlockFrequencyInfo::MachineBlockFrequencyInfo ( MachineFunction F,
MachineBranchProbabilityInfo MBPI,
MachineLoopInfo MLI 
)
explicit

Definition at line 204 of file MachineBlockFrequencyInfo.cpp.

References calculate(), and F.

◆ MachineBlockFrequencyInfo() [3/3]

MachineBlockFrequencyInfo::MachineBlockFrequencyInfo ( MachineBlockFrequencyInfo &&  )
default

◆ ~MachineBlockFrequencyInfo()

MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo ( )
default

Member Function Documentation

◆ calculate()

void MachineBlockFrequencyInfo::calculate ( const MachineFunction F,
const MachineBranchProbabilityInfo MBPI,
const MachineLoopInfo MLI 
)

◆ getBlockFreq()

BlockFrequency MachineBlockFrequencyInfo::getBlockFreq ( const MachineBasicBlock MBB) const

getblockFreq - Return block frequency.

Return 0 if we don't have the information. Please note that initial frequency is equal to 1024. 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. For example, to get the frequency of a block relative to the entry block, divide the integral value returned by this function (the BlockFrequency::getFrequency() value) by getEntryFreq().

Definition at line 268 of file MachineBlockFrequencyInfo.cpp.

References MBB.

Referenced by llvm::RegBankSelect::computeMapping(), llvm::AsmPrinter::emitBBAddrMapSection(), llvm::RegBankSelect::InstrInsertPoint::frequency(), llvm::RegBankSelect::MBBInsertPoint::frequency(), llvm::RegBankSelect::EdgeInsertPoint::frequency(), llvm::MBFIWrapper::getBlockFreq(), getBlockFreqRelativeToEntryBlock(), and llvm::printBlockFreq().

◆ getBlockFreqRelativeToEntryBlock()

double llvm::MachineBlockFrequencyInfo::getBlockFreqRelativeToEntryBlock ( const MachineBasicBlock MBB) const
inline

Compute the frequency of the block, relative to the entry block.

This API assumes getEntryFreq() is non-zero.

Definition at line 70 of file MachineBlockFrequencyInfo.h.

References assert(), getBlockFreq(), getEntryFreq(), llvm::BlockFrequency::getFrequency(), and MBB.

Referenced by llvm::calculateRegAllocScore(), and llvm::LiveIntervals::getSpillWeight().

◆ getBlockProfileCount()

std::optional< uint64_t > MachineBlockFrequencyInfo::getBlockProfileCount ( const MachineBasicBlock MBB) const

Definition at line 272 of file MachineBlockFrequencyInfo.cpp.

References F, and MBB.

Referenced by llvm::MBFIWrapper::getBlockProfileCount(), and isColdBlock().

◆ getEntryFreq()

BlockFrequency MachineBlockFrequencyInfo::getEntryFreq ( ) const

Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relative frequency of said block.

Definition at line 315 of file MachineBlockFrequencyInfo.cpp.

Referenced by getBlockFreqRelativeToEntryBlock(), llvm::MBFIWrapper::getEntryFreq(), and llvm::printBlockFreq().

◆ getFunction()

const MachineFunction * MachineBlockFrequencyInfo::getFunction ( ) const

Definition at line 307 of file MachineBlockFrequencyInfo.cpp.

◆ getMBPI()

const MachineBranchProbabilityInfo * MachineBlockFrequencyInfo::getMBPI ( ) const

◆ getProfileCountFromFreq()

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

Definition at line 282 of file MachineBlockFrequencyInfo.cpp.

References F.

Referenced by llvm::MBFIWrapper::getBlockProfileCount().

◆ invalidate()

bool MachineBlockFrequencyInfo::invalidate ( MachineFunction F,
const PreservedAnalyses PA,
MachineFunctionAnalysisManager::Invalidator  
)

Handle invalidation explicitly.

Definition at line 212 of file MachineBlockFrequencyInfo.cpp.

References llvm::PreservedAnalyses::getChecker().

◆ isIrrLoopHeader()

bool MachineBlockFrequencyInfo::isIrrLoopHeader ( const MachineBasicBlock MBB) const

Definition at line 290 of file MachineBlockFrequencyInfo.cpp.

References assert(), and MBB.

◆ onEdgeSplit()

void MachineBlockFrequencyInfo::onEdgeSplit ( const MachineBasicBlock NewPredecessor,
const MachineBasicBlock NewSuccessor,
const MachineBranchProbabilityInfo MBPI 
)

incrementally calculate block frequencies when we split edges, to avoid full CFG traversal.

Definition at line 296 of file MachineBlockFrequencyInfo.cpp.

References assert(), and llvm::MachineBranchProbabilityInfo::getEdgeProbability().

◆ print()

void MachineBlockFrequencyInfo::print ( raw_ostream OS)

Definition at line 256 of file MachineBlockFrequencyInfo.cpp.

References OS.

◆ releaseMemory()

void MachineBlockFrequencyInfo::releaseMemory ( )

◆ view()

void MachineBlockFrequencyInfo::view ( const Twine Name,
bool  isSimple = true 
) const

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

Definition at line 262 of file MachineBlockFrequencyInfo.cpp.

References isSimple(), Name, and llvm::ViewGraph().

Referenced by calculate(), and llvm::MBFIWrapper::view().


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