LLVM 22.0.0git
llvm::MachineBlockFrequencyInfo Class Reference

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

#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"

Public Member Functions

LLVM_ABI MachineBlockFrequencyInfo ()
LLVM_ABI MachineBlockFrequencyInfo (const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, const MachineLoopInfo &MLI)
LLVM_ABI MachineBlockFrequencyInfo (MachineBlockFrequencyInfo &&)
LLVM_ABI ~MachineBlockFrequencyInfo ()
LLVM_ABI bool invalidate (MachineFunction &F, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &)
 Handle invalidation explicitly.
LLVM_ABI void calculate (const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, const MachineLoopInfo &MLI)
 calculate - compute block frequency info for the given function.
LLVM_ABI void print (raw_ostream &OS)
LLVM_ABI void releaseMemory ()
LLVM_ABI 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.
LLVM_ABI std::optional< uint64_tgetBlockProfileCount (const MachineBasicBlock *MBB) const
LLVM_ABI std::optional< uint64_tgetProfileCountFromFreq (BlockFrequency Freq) const
LLVM_ABI bool isIrrLoopHeader (const MachineBasicBlock *MBB) const
LLVM_ABI void onEdgeSplit (const MachineBasicBlock &NewPredecessor, const MachineBasicBlock &NewSuccessor, const MachineBranchProbabilityInfo &MBPI)
 incrementally calculate block frequencies when we split edges, to avoid full CFG traversal.
LLVM_ABI const MachineFunctiongetFunction () const
LLVM_ABI const MachineBranchProbabilityInfogetMBPI () const
LLVM_ABI void view (const Twine &Name, bool isSimple=true) const
 Pop up a ghostview window with the current block frequency propagation rendered using dot.
LLVM_ABI 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 35 of file MachineBlockFrequencyInfo.h.

Constructor & Destructor Documentation

◆ MachineBlockFrequencyInfo() [1/3]

MachineBlockFrequencyInfo::MachineBlockFrequencyInfo ( )
default

References F, and LLVM_ABI.

Referenced by MachineBlockFrequencyInfo(), and view().

◆ MachineBlockFrequencyInfo() [2/3]

MachineBlockFrequencyInfo::MachineBlockFrequencyInfo ( const MachineFunction & F,
const MachineBranchProbabilityInfo & MBPI,
const 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

References F, LLVM_ABI, and MBB.

Member Function Documentation

◆ calculate()

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

calculate - compute block frequency info for the given function.

Definition at line 231 of file MachineBlockFrequencyInfo.cpp.

References llvm::dbgs(), F, llvm::GVDT_None, llvm::PrintBFIFuncName, llvm::PrintMachineBlockFreq, view(), llvm::ViewBlockFreqFuncName, and llvm::ViewMachineBlockFreqPropagationDAG.

Referenced by MachineBlockFrequencyInfo().

◆ 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::AsmPrinter::emitBBAddrMapSection(), llvm::RegBankSelect::InstrInsertPoint::frequency(), llvm::RegBankSelect::MBBInsertPoint::frequency(), 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 71 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 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(), and llvm::printBlockFreq().

◆ getFunction()

const MachineFunction * MachineBlockFrequencyInfo::getFunction ( ) const

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

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

◆ releaseMemory()

void MachineBlockFrequencyInfo::releaseMemory ( )

Definition at line 258 of file MachineBlockFrequencyInfo.cpp.

◆ 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(), MachineBlockFrequencyInfo(), and llvm::ViewGraph().

Referenced by calculate().


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