|
LLVM
10.0.0
|
Base class for BlockFrequencyInfoImpl. More...
#include "llvm/Analysis/BlockFrequencyInfoImpl.h"
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 | |
| using | Scaled64 = ScaledNumber< uint64_t > |
| using | BlockMass = bfi_detail::BlockMass |
Public Attributes | |
| std::vector< FrequencyData > | Freqs |
| Data about each block. This is used downstream. More... | |
| SparseBitVector | IsIrrLoopHeader |
| Whether each block is an irreducible loop header. More... | |
| std::vector< WorkingData > | Working |
| Loop data: see initializeLoops(). More... | |
| std::list< LoopData > | Loops |
| Indexed information about loops. More... | |
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 170 of file BlockFrequencyInfoImpl.h.
Definition at line 173 of file BlockFrequencyInfoImpl.h.
| using llvm::BlockFrequencyInfoImplBase::Scaled64 = ScaledNumber<uint64_t> |
Definition at line 172 of file BlockFrequencyInfoImpl.h.
|
virtualdefault |
Virtual destructor.
Need a virtual destructor to mask the compiler warning about getBlockName().
| 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.
true unless there's an irreducible backedge. Definition at line 352 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).
true unless aborted due to an irreducible backedge. Definition at line 290 of file BlockFrequencyInfoImpl.cpp.
| 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 805 of file BlockFrequencyInfoImpl.cpp.
References llvm::BlockFrequencyInfoImplBase::Distribution::addLocal(), llvm::BlockFrequencyInfoImplBase::Weight::Amount, assert(), llvm::BlockFrequencyInfoImplBase::LoopData::BackedgeMass, D, llvm::dbgs(), debugAssign(), llvm::bfi_detail::getBlockName(), llvm::bfi_detail::BlockMass::getFull(), llvm::BlockFrequencyInfoImplBase::LoopData::getHeaderIndex(), H, llvm::BlockFrequencyInfoImplBase::BlockNode::Index, llvm::BlockFrequencyInfoImplBase::LoopData::isIrreducible(), LLVM_DEBUG, llvm::BlockFrequencyInfoImplBase::LoopData::Nodes, llvm::BlockFrequencyInfoImplBase::LoopData::NumHeaders, llvm::BlockFrequencyInfoImplBase::Weight::TargetNode, llvm::BlockFrequencyInfoImplBase::Weight::Type, llvm::RISCVFenceField::W, and llvm::BlockFrequencyInfoImplBase::Distribution::Weights.
| 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.
LoopData nodes representing the irreducible SCCs. Definition at line 774 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 270 of file BlockFrequencyInfoImpl.cpp.
References Loops, and std::swap().
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::calculate(), and cleanup().
| void BlockFrequencyInfoImplBase::computeLoopScale | ( | LoopData & | Loop | ) |
Compute the loop scale for a loop.
Definition at line 365 of file BlockFrequencyInfoImpl.cpp.
References llvm::BlockFrequencyInfoImplBase::LoopData::BackedgeMass, llvm::dbgs(), llvm::bfi_detail::BlockMass::getFull(), llvm::ScaledNumber< DigitsT >::inverse(), llvm::bfi_detail::BlockMass::isEmpty(), LLVM_DEBUG, llvm::BlockFrequencyInfoImplBase::LoopData::Scale, and llvm::bfi_detail::BlockMass::toScaled().
| void BlockFrequencyInfoImplBase::distributeIrrLoopHeaderMass | ( | Distribution & | Dist | ) |
Definition at line 842 of file BlockFrequencyInfoImpl.cpp.
References llvm::BlockFrequencyInfoImplBase::Weight::Amount, assert(), D, debugAssign(), llvm::bfi_detail::BlockMass::getFull(), llvm::BlockFrequencyInfoImplBase::BlockNode::Index, LLVM_DEBUG, llvm::BlockFrequencyInfoImplBase::Weight::TargetNode, llvm::BlockFrequencyInfoImplBase::Weight::Type, llvm::RISCVFenceField::W, and llvm::BlockFrequencyInfoImplBase::Distribution::Weights.
| void BlockFrequencyInfoImplBase::distributeMass | ( | const BlockNode & | Source, |
| LoopData * | OuterLoop, | ||
| Distribution & | Dist | ||
| ) |
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 425 of file BlockFrequencyInfoImpl.cpp.
References llvm::BlockFrequencyInfoImplBase::Weight::Amount, assert(), llvm::BlockFrequencyInfoImplBase::LoopData::BackedgeMass, D, llvm::dbgs(), debugAssign(), llvm::BlockFrequencyInfoImplBase::LoopData::Exits, llvm::BlockFrequencyInfoImplBase::LoopData::getHeaderIndex(), llvm::bfi_detail::BlockMass::getMass(), llvm::BlockFrequencyInfoImplBase::BlockNode::Index, LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::BlockFrequencyInfoImplBase::Weight::TargetNode, llvm::BlockFrequencyInfoImplBase::Weight::Type, llvm::RISCVFenceField::W, and llvm::BlockFrequencyInfoImplBase::Distribution::Weights.
|
inline |
Definition at line 517 of file BlockFrequencyInfoImpl.h.
References llvm::dbgs(), F(), and llvm::bfi_detail::BlockMass::print().
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getBPI().
| void BlockFrequencyInfoImplBase::finalizeMetrics | ( | ) |
Finalize frequency metrics.
Calculates final frequencies and cleans up no-longer-needed data structures.
Definition at line 530 of file BlockFrequencyInfoImpl.cpp.
References cleanup(), convertFloatingToInteger(), llvm::bfi_detail::BlockMass::dump(), LLVM_DEBUG, llvm::max(), and Scaled.
| BlockFrequency BlockFrequencyInfoImplBase::getBlockFreq | ( | const BlockNode & | Node | ) | const |
Definition at line 552 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getBlockFreq().
Definition at line 606 of file BlockFrequencyInfoImpl.cpp.
Referenced by convertFloatingToInteger(), debugAssign(), findIrreducibleHeaders(), and unwrapLoop().
| Optional< uint64_t > BlockFrequencyInfoImplBase::getBlockProfileCount | ( | const Function & | F, |
| const BlockNode & | Node, | ||
| bool | AllowSynthetic = false |
||
| ) | const |
Definition at line 559 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getBlockProfileCount(), and llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::print().
|
inline |
Definition at line 536 of file BlockFrequencyInfoImpl.h.
References assert().
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getFunction().
Definition at line 592 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getFloatingBlockFreq().
Definition at line 611 of file BlockFrequencyInfoImpl.cpp.
References llvm::bfi_detail::getBlockName(), llvm::BlockFrequencyInfoImplBase::LoopData::getHeader(), and llvm::BlockFrequencyInfoImplBase::LoopData::isIrreducible().
Referenced by unwrapLoop().
Definition at line 449 of file BlockFrequencyInfoImpl.h.
References assert(), clear(), G, llvm::bfi_detail::getBlockName(), llvm::BlockFrequencyInfoImplBase::BlockNode::Index, and llvm::Sched::Source.
| Optional< uint64_t > BlockFrequencyInfoImplBase::getProfileCountFromFreq | ( | const Function & | F, |
| uint64_t | Freq, | ||
| bool | AllowSynthetic = false |
||
| ) | const |
Definition at line 567 of file BlockFrequencyInfoImpl.cpp.
References llvm::Function::getEntryCount(), llvm::APInt::lshr(), and llvm::None.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getProfileCountFromFreq().
Definition at line 585 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::isIrrLoopHeader().
| void BlockFrequencyInfoImplBase::packageLoop | ( | LoopData & | Loop | ) |
Package up a loop.
Definition at line 400 of file BlockFrequencyInfoImpl.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::BlockFrequencyInfoImplBase::LoopData::Exits, llvm::bfi_detail::getBlockName(), llvm::BlockFrequencyInfoImplBase::BlockNode::Index, llvm::BlockFrequencyInfoImplBase::LoopData::IsPackaged, LLVM_DEBUG, and llvm::BlockFrequencyInfoImplBase::LoopData::Nodes.
|
inlinevirtual |
Reimplemented in llvm::BlockFrequencyInfoImpl< BT >, and llvm::BlockFrequencyInfoImpl< llvm::BitTracker >.
Definition at line 516 of file BlockFrequencyInfoImpl.h.
| raw_ostream & BlockFrequencyInfoImplBase::printBlockFreq | ( | raw_ostream & | OS, |
| const BlockNode & | Node | ||
| ) | const |
Definition at line 616 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::getBPI(), and llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::printBlockFreq().
| raw_ostream & BlockFrequencyInfoImplBase::printBlockFreq | ( | raw_ostream & | OS, |
| const BlockFrequency & | Freq | ||
| ) | const |
Definition at line 622 of file BlockFrequencyInfoImpl.cpp.
References llvm::BlockFrequency::getFrequency().
Definition at line 598 of file BlockFrequencyInfoImpl.cpp.
Referenced by llvm::BlockFrequencyInfoImpl< llvm::BitTracker >::setBlockFreq().
| void BlockFrequencyInfoImplBase::unwrapLoops | ( | ) |
Unwrap loops.
Definition at line 521 of file BlockFrequencyInfoImpl.cpp.
References Loops, Scaled, 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 794 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, llvm::BlockFrequencyInfoImplBase::LoopData::Nodes, and llvm::RISCVFenceField::O.
| std::vector<FrequencyData> llvm::BlockFrequencyInfoImplBase::Freqs |
Data about each block. This is used downstream.
Definition at line 412 of file BlockFrequencyInfoImpl.h.
Referenced by cleanup(), convertFloatingToInteger(), and unwrapLoop().
| SparseBitVector llvm::BlockFrequencyInfoImplBase::IsIrrLoopHeader |
Whether each block is an irreducible loop header.
This is used downstream.
Definition at line 416 of file BlockFrequencyInfoImpl.h.
Referenced by cleanup().
| std::list<LoopData> llvm::BlockFrequencyInfoImplBase::Loops |
Indexed information about loops.
Definition at line 422 of file BlockFrequencyInfoImpl.h.
Referenced by createIrreducibleLoop().
| std::vector<WorkingData> llvm::BlockFrequencyInfoImplBase::Working |
Loop data: see initializeLoops().
Definition at line 419 of file BlockFrequencyInfoImpl.h.
Referenced by llvm::bfi_detail::IrreducibleGraph::addNode(), createIrreducibleLoop(), and unwrapLoop().
1.8.13