LLVM: llvm::BlockFrequencyInfoImplBase Class Reference (original) (raw)

Base class for BlockFrequencyInfoImpl. More...

#include "[llvm/Analysis/BlockFrequencyInfoImpl.h](BlockFrequencyInfoImpl%5F8h%5Fsource.html)"

Classes
struct BlockNode
Representative of a block. More...
struct Distribution
Distribution of unscaled probability weight. More...
struct FrequencyData
Stats about a block itself. More...
struct LoopData
Data about a loop. More...
struct Weight
Unscaled probability weight. More...
struct WorkingData
Index of loop information. More...
Public Member Functions
virtual ~BlockFrequencyInfoImplBase ()=default
Virtual destructor.
bool addLoopSuccessorsToDist (const LoopData *OuterLoop, LoopData &Loop, Distribution &Dist)
Add all edges out of a packaged loop to the distribution.
bool addToDist (Distribution &Dist, const LoopData *OuterLoop, const BlockNode &Pred, const BlockNode &Succ, uint64_t Weight)
Add an edge to the distribution.
iterator_range< std::list< LoopData >::iterator > analyzeIrreducible (const bfi_detail::IrreducibleGraph &G, LoopData *OuterLoop, std::list< LoopData >::iterator Insert)
Analyze irreducible SCCs.
void updateLoopWithIrreducible (LoopData &OuterLoop)
Update a loop after packaging irreducible SCCs inside of it.
void distributeMass (const BlockNode &Source, LoopData *OuterLoop, Distribution &Dist)
Distribute mass according to a distribution.
void computeLoopScale (LoopData &Loop)
Compute the loop scale for a loop.
void adjustLoopHeaderMass (LoopData &Loop)
Adjust the mass of all headers in an irreducible loop.
void distributeIrrLoopHeaderMass (Distribution &Dist)
void packageLoop (LoopData &Loop)
Package up a loop.
void unwrapLoops ()
Unwrap loops.
void finalizeMetrics ()
Finalize frequency metrics.
void clear ()
Clear all memory.
virtual std::string getBlockName (const BlockNode &Node) const
std::string getLoopName (const LoopData &Loop) const
virtual raw_ostream & print (raw_ostream &OS) const
void dump () const
Scaled64 getFloatingBlockFreq (const BlockNode &Node) const
BlockFrequency getBlockFreq (const BlockNode &Node) const
std::optional< uint64_t > getBlockProfileCount (const Function &F, const BlockNode &Node, bool AllowSynthetic=false) const
std::optional< uint64_t > getProfileCountFromFreq (const Function &F, BlockFrequency Freq, bool AllowSynthetic=false) const
bool isIrrLoopHeader (const BlockNode &Node)
void setBlockFreq (const BlockNode &Node, BlockFrequency Freq)
BlockFrequency getEntryFreq () const
Public Attributes
std::vector< FrequencyData > Freqs
Data about each block. This is used downstream.
SparseBitVector IsIrrLoopHeader
Whether each block is an irreducible loop header.
std::vector< WorkingData > Working
Loop data: see initializeLoops().
std::list< LoopData > Loops
Indexed information about loops.

Base class for BlockFrequencyInfoImpl.

BlockFrequencyInfoImplBase has supporting data structures and some algorithms for BlockFrequencyInfoImplBase. Only algorithms that depend on the block type (or that call such algorithms) are skipped here.

Nevertheless, the majority of the overall algorithm documentation lives with BlockFrequencyInfoImpl. See there for details.

Definition at line 177 of file BlockFrequencyInfoImpl.h.

BlockMass

Scaled64

virtual llvm::BlockFrequencyInfoImplBase::~BlockFrequencyInfoImplBase ( ) virtualdefault

Virtual destructor.

Need a virtual destructor to mask the compiler warning about getBlockName().

References G.

addLoopSuccessorsToDist()

addToDist()

Add an edge to the distribution.

Adds an edge to Succ to Dist. If LoopHead.isValid(), then whether the edge is local/exit/backedge is in the context of LoopHead. Otherwise, every edge should be a local edge (since all the loops are packaged up).

Returns

true unless aborted due to an irreducible backedge.

Definition at line 312 of file BlockFrequencyInfoImpl.cpp.

References llvm::BlockFrequencyInfoImplBase::Distribution::addBackedge(), llvm::BlockFrequencyInfoImplBase::Distribution::addExit(), llvm::BlockFrequencyInfoImplBase::Distribution::addLocal(), assert(), llvm::dbgs(), llvm::bfi_detail::getBlockName(), llvm::BlockFrequencyInfoImplBase::BlockNode::Index, llvm::BlockFrequencyInfoImplBase::LoopData::isHeader(), llvm::BlockFrequencyInfoImplBase::LoopData::isIrreducible(), LLVM_DEBUG, and Working.

Referenced by addLoopSuccessorsToDist().

adjustLoopHeaderMass()

void BlockFrequencyInfoImplBase::adjustLoopHeaderMass ( LoopData & Loop )

Adjust the mass of all headers in an irreducible loop.

Initially, irreducible loops are assumed to distribute their mass equally among its headers. This can lead to wrong frequency estimates since some headers may be executed more frequently than others.

This adjusts header mass distribution so it matches the weights of the backedges going into each of the loop headers.

Definition at line 812 of file BlockFrequencyInfoImpl.cpp.

References llvm::BlockFrequencyInfoImplBase::Distribution::addLocal(), assert(), D(), llvm::dbgs(), debugAssign(), llvm::bfi_detail::getBlockName(), llvm::bfi_detail::BlockMass::getFull(), H, LLVM_DEBUG, llvm::BlockFrequencyInfoImplBase::Weight::Local, llvm::BlockFrequencyInfoImplBase::Distribution::Weights, and Working.

analyzeIrreducible()

clear()

void BlockFrequencyInfoImplBase::clear ( )

computeLoopScale()

void BlockFrequencyInfoImplBase::computeLoopScale ( LoopData & Loop )

distributeIrrLoopHeaderMass()

void BlockFrequencyInfoImplBase::distributeIrrLoopHeaderMass ( Distribution & Dist )

distributeMass()

Distribute mass according to a distribution.

Distributes the mass in Source according to Dist. If LoopHead.isValid(), backedges and exits are stored in its entry in Loops.

Mass is distributed in parallel from two copies of the source mass.

Definition at line 447 of file BlockFrequencyInfoImpl.cpp.

References assert(), llvm::BlockFrequencyInfoImplBase::Weight::Backedge, llvm::BlockFrequencyInfoImplBase::LoopData::BackedgeMass, D(), llvm::dbgs(), debugAssign(), llvm::BlockFrequencyInfoImplBase::Weight::Exit, llvm::BlockFrequencyInfoImplBase::LoopData::Exits, llvm::BlockFrequencyInfoImplBase::LoopData::getHeaderIndex(), LLVM_DEBUG, llvm::BlockFrequencyInfoImplBase::Weight::Local, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::BlockFrequencyInfoImplBase::Distribution::Weights, and Working.

dump()

void llvm::BlockFrequencyInfoImplBase::dump ( ) const inline

finalizeMetrics()

void BlockFrequencyInfoImplBase::finalizeMetrics ( )

getBlockFreq()

getBlockName()

std::string BlockFrequencyInfoImplBase::getBlockName ( const BlockNode & Node) const virtual

getBlockProfileCount()

getEntryFreq()

BlockFrequency llvm::BlockFrequencyInfoImplBase::getEntryFreq ( ) const inline

getFloatingBlockFreq()

Scaled64 BlockFrequencyInfoImplBase::getFloatingBlockFreq ( const BlockNode & Node ) const

getLoopName()

std::string BlockFrequencyInfoImplBase::getLoopName ( const LoopData & Loop ) const

getProfileCountFromFreq()

isIrrLoopHeader()

packageLoop()

void BlockFrequencyInfoImplBase::packageLoop ( LoopData & Loop )

print()

setBlockFreq()

unwrapLoops()

void BlockFrequencyInfoImplBase::unwrapLoops ( )

updateLoopWithIrreducible()

void BlockFrequencyInfoImplBase::updateLoopWithIrreducible ( LoopData & OuterLoop )

Update a loop after packaging irreducible SCCs inside of it.

Update OuterLoop. Before finding irreducible control flow, it was partway through computeMassInLoop(), so LoopData::Exits and LoopData::BackedgeMass need to be reset. Also, nodes that were packaged up need to be removed from OuterLoop::Nodes.

Definition at line 801 of file BlockFrequencyInfoImpl.cpp.

References llvm::BlockFrequencyInfoImplBase::LoopData::BackedgeMass, llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorImpl< T >::erase(), llvm::BlockFrequencyInfoImplBase::LoopData::Exits, llvm::bfi_detail::BlockMass::getEmpty(), I, llvm::BlockFrequencyInfoImplBase::LoopData::Nodes, and Working.

Freqs

std::vector<FrequencyData> llvm::BlockFrequencyInfoImplBase::Freqs

Data about each block. This is used downstream.

Definition at line 419 of file BlockFrequencyInfoImpl.h.

Referenced by cleanup(), clear(), convertFloatingToInteger(), finalizeMetrics(), getBlockFreq(), getEntryFreq(), getFloatingBlockFreq(), llvm::BlockFrequencyInfoImpl< BT >::setBlockFreq(), setBlockFreq(), unwrapLoop(), unwrapLoops(), and llvm::BlockFrequencyInfoImpl< BT >::verifyMatch().

IsIrrLoopHeader

Loops

std::list<LoopData> llvm::BlockFrequencyInfoImplBase::Loops

Working

std::vector<WorkingData> llvm::BlockFrequencyInfoImplBase::Working

Loop data: see initializeLoops().

Definition at line 426 of file BlockFrequencyInfoImpl.h.

Referenced by addToDist(), adjustLoopHeaderMass(), clear(), createIrreducibleLoop(), distributeIrrLoopHeaderMass(), distributeMass(), finalizeMetrics(), packageLoop(), unwrapLoop(), unwrapLoops(), and updateLoopWithIrreducible().


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