LLVM  4.0.0
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
llvm::BlockFrequencyInfoImplBase Class Reference

Base class for BlockFrequencyInfoImpl. More...

#include <BlockFrequencyInfoImpl.h>

Inheritance diagram for llvm::BlockFrequencyInfoImplBase:
[legend]
Collaboration diagram for llvm::BlockFrequencyInfoImplBase:
[legend]

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 Types

typedef ScaledNumber< uint64_t > Scaled64
 
typedef bfi_detail::BlockMass BlockMass
 

Public Member Functions

bool addLoopSuccessorsToDist (const LoopData *OuterLoop, LoopData &Loop, Distribution &Dist)
 Add all edges out of a packaged loop to the distribution. More...
 
bool addToDist (Distribution &Dist, const LoopData *OuterLoop, const BlockNode &Pred, const BlockNode &Succ, uint64_t Weight)
 Add an edge to the distribution. More...
 
LoopDatagetLoopPackage (const BlockNode &Head)
 
iterator_range< std::list
< LoopData >::iterator > 
analyzeIrreducible (const bfi_detail::IrreducibleGraph &G, LoopData *OuterLoop, std::list< LoopData >::iterator Insert)
 Analyze irreducible SCCs. More...
 
void updateLoopWithIrreducible (LoopData &OuterLoop)
 Update a loop after packaging irreducible SCCs inside of it. More...
 
void distributeMass (const BlockNode &Source, LoopData *OuterLoop, Distribution &Dist)
 Distribute mass according to a distribution. More...
 
void computeLoopScale (LoopData &Loop)
 Compute the loop scale for a loop. More...
 
void adjustLoopHeaderMass (LoopData &Loop)
 Adjust the mass of all headers in an irreducible loop. More...
 
void packageLoop (LoopData &Loop)
 Package up a loop. More...
 
void unwrapLoops ()
 Unwrap loops. More...
 
void finalizeMetrics ()
 Finalize frequency metrics. More...
 
void clear ()
 Clear all memory. More...
 
virtual std::string getBlockName (const BlockNode &Node) const
 
std::string getLoopName (const LoopData &Loop) const
 
virtual raw_ostreamprint (raw_ostream &OS) const
 
void dump () const
 
Scaled64 getFloatingBlockFreq (const BlockNode &Node) const
 
BlockFrequency getBlockFreq (const BlockNode &Node) const
 
Optional< uint64_t > getBlockProfileCount (const Function &F, const BlockNode &Node) const
 
Optional< uint64_t > getProfileCountFromFreq (const Function &F, uint64_t Freq) const
 
void setBlockFreq (const BlockNode &Node, uint64_t Freq)
 
raw_ostreamprintBlockFreq (raw_ostream &OS, const BlockNode &Node) const
 
raw_ostreamprintBlockFreq (raw_ostream &OS, const BlockFrequency &Freq) const
 
uint64_t getEntryFreq () const
 
virtual ~BlockFrequencyInfoImplBase ()
 Virtual destructor. More...
 

Public Attributes

std::vector< FrequencyDataFreqs
 Data about each block. This is used downstream. More...
 
std::vector< WorkingDataWorking
 Loop data: see initializeLoops(). More...
 
std::list< LoopDataLoops
 Indexed information about loops. More...
 

Detailed Description

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 documention lives with BlockFrequencyInfoImpl. See there for details.

Definition at line 160 of file BlockFrequencyInfoImpl.h.

Member Typedef Documentation

Definition at line 163 of file BlockFrequencyInfoImpl.h.

Definition at line 162 of file BlockFrequencyInfoImpl.h.

Constructor & Destructor Documentation

virtual llvm::BlockFrequencyInfoImplBase::~BlockFrequencyInfoImplBase ( )
inlinevirtual

Virtual destructor.

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

Definition at line 502 of file BlockFrequencyInfoImpl.h.

Member Function Documentation

bool BlockFrequencyInfoImplBase::addLoopSuccessorsToDist ( const LoopData OuterLoop,
LoopData Loop,
Distribution Dist 
)

Add all edges out of a packaged loop to the distribution.

Adds all edges from LocalLoopHead to Dist. Calls addToDist() to add each successor edge.

Returns
true unless there's an irreducible backedge.

Definition at line 328 of file BlockFrequencyInfoImpl.cpp.

References llvm::BlockFrequencyInfoImplBase::LoopData::Exits, llvm::BlockFrequencyInfoImplBase::LoopData::getHeader(), and I.

bool BlockFrequencyInfoImplBase::addToDist ( Distribution Dist,
const LoopData OuterLoop,
const BlockNode Pred,
const BlockNode Succ,
uint64_t  Weight 
)

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 266 of file BlockFrequencyInfoImpl.cpp.

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

void BlockFrequencyInfoImplBase::adjustLoopHeaderMass ( LoopData Loop)
iterator_range< std::list< LoopData >::iterator > BlockFrequencyInfoImplBase::analyzeIrreducible ( const bfi_detail::IrreducibleGraph G,
LoopData OuterLoop,
std::list< LoopData >::iterator  Insert 
)

Analyze irreducible SCCs.

Separate irreducible SCCs from G, which is an explict graph of OuterLoop (or the top-level function, if OuterLoop is nullptr). Insert them into Loops before Insert.

Returns
the LoopData nodes representing the irreducible SCCs.

Definition at line 734 of file BlockFrequencyInfoImpl.cpp.

References assert(), createIrreducibleLoop(), I, Loops, llvm::make_range(), and llvm::scc_begin().

void BlockFrequencyInfoImplBase::clear ( )

Clear all memory.

Definition at line 249 of file BlockFrequencyInfoImpl.cpp.

References Loops, and std::swap().

Referenced by llvm::BlockFrequencyInfoImpl< BlockT >::calculate(), and cleanup().

void BlockFrequencyInfoImplBase::computeLoopScale ( LoopData Loop)
void BlockFrequencyInfoImplBase::distributeMass ( const BlockNode Source,
LoopData OuterLoop,
Distribution Dist 
)
void llvm::BlockFrequencyInfoImplBase::dump ( ) const
inline

Definition at line 478 of file BlockFrequencyInfoImpl.h.

References llvm::dbgs(), and print().

void BlockFrequencyInfoImplBase::finalizeMetrics ( )

Finalize frequency metrics.

Calculates final frequencies and cleans up no-longer-needed data structures.

Definition at line 505 of file BlockFrequencyInfoImpl.cpp.

References cleanup(), convertFloatingToInteger(), DEBUG, llvm::dump(), and fuzzer::min().

BlockFrequency BlockFrequencyInfoImplBase::getBlockFreq ( const BlockNode Node) const
std::string BlockFrequencyInfoImplBase::getBlockName ( const BlockNode Node) const
virtual
Optional< uint64_t > BlockFrequencyInfoImplBase::getBlockProfileCount ( const Function F,
const BlockNode Node 
) const
uint64_t llvm::BlockFrequencyInfoImplBase::getEntryFreq ( ) const
inline

Definition at line 494 of file BlockFrequencyInfoImpl.h.

References assert(), and Freqs.

Scaled64 BlockFrequencyInfoImplBase::getFloatingBlockFreq ( const BlockNode Node) const
std::string BlockFrequencyInfoImplBase::getLoopName ( const LoopData Loop) const
LoopData& llvm::BlockFrequencyInfoImplBase::getLoopPackage ( const BlockNode Head)
inline
Optional< uint64_t > BlockFrequencyInfoImplBase::getProfileCountFromFreq ( const Function F,
uint64_t  Freq 
) const
void BlockFrequencyInfoImplBase::packageLoop ( LoopData Loop)
virtual raw_ostream& llvm::BlockFrequencyInfoImplBase::print ( raw_ostream OS) const
inlinevirtual
raw_ostream & BlockFrequencyInfoImplBase::printBlockFreq ( raw_ostream OS,
const BlockNode Node 
) const
raw_ostream & BlockFrequencyInfoImplBase::printBlockFreq ( raw_ostream OS,
const BlockFrequency Freq 
) const

Definition at line 585 of file BlockFrequencyInfoImpl.cpp.

References llvm::BlockFrequency::getFrequency().

void BlockFrequencyInfoImplBase::setBlockFreq ( const BlockNode Node,
uint64_t  Freq 
)
void BlockFrequencyInfoImplBase::unwrapLoops ( )

Unwrap loops.

Definition at line 496 of file BlockFrequencyInfoImpl.cpp.

References Loops, llvm::bfi_detail::BlockMass::toScaled(), and unwrapLoop().

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 754 of file BlockFrequencyInfoImpl.cpp.

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

Member Data Documentation

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

Data about each block. This is used downstream.

Definition at line 385 of file BlockFrequencyInfoImpl.h.

Referenced by cleanup(), convertFloatingToInteger(), getEntryFreq(), and unwrapLoop().

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

Indexed information about loops.

Definition at line 391 of file BlockFrequencyInfoImpl.h.

Referenced by createIrreducibleLoop().

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

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