LLVM 22.0.0git
llvm::RawInstrProfReader< IntPtrT > Class Template Reference

Reader for the raw instrprof binary format from runtime. More...

#include "llvm/ProfileData/InstrProfReader.h"

Inheritance diagram for llvm::RawInstrProfReader< IntPtrT >:
[legend]

Public Member Functions

 RawInstrProfReader (std::unique_ptr< MemoryBuffer > DataBuffer, const InstrProfCorrelator *Correlator, const object::BuildIDFetcher *BIDFetcher, const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind, std::function< void(Error)> Warn)
 RawInstrProfReader (const RawInstrProfReader &)=delete
RawInstrProfReaderoperator= (const RawInstrProfReader &)=delete
Error readHeader () override
 Read the header. Required before reading first record.
Error readNextRecord (NamedInstrProfRecord &Record) override
 Read a single record.
Error readBinaryIds (std::vector< llvm::object::BuildID > &BinaryIds) override
 Read a list of binary ids.
Error printBinaryIds (raw_ostream &OS) override
 Print binary ids.
uint64_t getVersion () const override
 Return the profile version.
bool isIRLevelProfile () const override
bool hasCSIRLevelProfile () const override
bool instrEntryBBEnabled () const override
bool instrLoopEntriesEnabled () const override
 Return true if the profile instruments all loop entries.
bool hasSingleByteCoverage () const override
 Return true if the profile has single byte counters representing coverage.
bool functionEntryOnly () const override
 Return true if the profile only instruments function entries.
bool hasMemoryProfile () const override
 Return true if profile includes a memory profile.
bool hasTemporalProfile () const override
 Return true if this has a temporal profile.
InstrProfKind getProfileKind () const override
 Returns a BitsetEnum describing the attributes of the raw instr profile.
InstrProfSymtabgetSymtab () override
 Return the PGO symtab.
SmallVector< TemporalProfTraceTy > & getTemporalProfTraces (std::optional< uint64_t > Weight={}) override
Public Member Functions inherited from llvm::InstrProfReader
 InstrProfReader ()=default
virtual ~InstrProfReader ()=default
InstrProfIterator begin ()
 Iterator over profile data.
InstrProfIterator end ()
LLVM_ABI void accumulateCounts (CountSumOrPercent &Sum, bool IsCS)
 Compute the sum of counts and return in Sum.
bool isEOF ()
 Return true if the reader has finished reading the profile data.
bool hasError ()
 Return true if the reader encountered an error reading profiling data.
Error getError ()
 Get the current error.
uint64_t getTemporalProfTraceStreamSize ()

Static Public Member Functions

static bool hasFormat (const MemoryBuffer &DataBuffer)
Static Public Member Functions inherited from llvm::InstrProfReader
static LLVM_ABI Expected< std::unique_ptr< InstrProfReader > > create (const Twine &Path, vfs::FileSystem &FS, const InstrProfCorrelator *Correlator=nullptr, const object::BuildIDFetcher *BIDFetcher=nullptr, const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind=InstrProfCorrelator::ProfCorrelatorKind::NONE, std::function< void(Error)> Warn=nullptr)
 Factory method to create an appropriately typed reader for the given instrprof file.
static LLVM_ABI Expected< std::unique_ptr< InstrProfReader > > create (std::unique_ptr< MemoryBuffer > Buffer, const InstrProfCorrelator *Correlator=nullptr, const object::BuildIDFetcher *BIDFetcher=nullptr, const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind=InstrProfCorrelator::ProfCorrelatorKind::NONE, std::function< void(Error)> Warn=nullptr)

Additional Inherited Members

Protected Member Functions inherited from llvm::InstrProfReader
Error error (instrprof_error Err, const std::string &ErrMsg="")
 Set the current error and return same.
Error error (Error &&E)
Error success ()
 Clear the current error and return a successful one.
Protected Attributes inherited from llvm::InstrProfReader
std::unique_ptr< InstrProfSymtabSymtab
SmallVector< TemporalProfTraceTyTemporalProfTraces
 A list of temporal profile traces.
uint64_t TemporalProfTraceStreamSize = 0
 The total number of temporal profile traces seen.

Detailed Description

template<class IntPtrT>
class llvm::RawInstrProfReader< IntPtrT >

Reader for the raw instrprof binary format from runtime.

This format is a raw memory dump of the instrumentation-based profiling data from the runtime. It has no index.

Templated on the unsigned type whose size matches pointers on the platform that wrote the profile.

Definition at line 328 of file InstrProfReader.h.

Constructor & Destructor Documentation

◆ RawInstrProfReader() [1/2]

template<class IntPtrT>
llvm::RawInstrProfReader< IntPtrT >::RawInstrProfReader ( std::unique_ptr< MemoryBuffer > DataBuffer,
const InstrProfCorrelator * Correlator,
const object::BuildIDFetcher * BIDFetcher,
const InstrProfCorrelator::ProfCorrelatorKind BIDFetcherCorrelatorKind,
std::function< void(Error)> Warn )
inline

Definition at line 378 of file InstrProfReader.h.

◆ RawInstrProfReader() [2/2]

template<class IntPtrT>
llvm::RawInstrProfReader< IntPtrT >::RawInstrProfReader ( const RawInstrProfReader< IntPtrT > & )
delete

Member Function Documentation

◆ functionEntryOnly()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::functionEntryOnly ( ) const
inlineoverridevirtual

Return true if the profile only instruments function entries.

Implements llvm::InstrProfReader.

Definition at line 421 of file InstrProfReader.h.

◆ getProfileKind()

template<class IntPtrT>
InstrProfKind RawInstrProfReader::getProfileKind ( ) const
overridevirtual

Returns a BitsetEnum describing the attributes of the raw instr profile.

Implements llvm::InstrProfReader.

Definition at line 478 of file InstrProfReader.cpp.

References getProfileKindFromVersion().

◆ getSymtab()

template<class IntPtrT>
InstrProfSymtab & llvm::RawInstrProfReader< IntPtrT >::getSymtab ( )
inlineoverridevirtual

Return the PGO symtab.

There are three different readers: Raw, Text, and Indexed profile readers. The first two types of readers are used only by llvm-profdata tool, while the indexed profile reader is also used by llvm-cov tool and the compiler ( backend or frontend). Since creating PGO symtab can create significant runtime and memory overhead (as it touches data for the whole program), InstrProfSymtab for the indexed profile reader should be created on demand and it is recommended to be only used for dumping purpose with llvm-proftool, not with the compiler.

Implements llvm::InstrProfReader.

Definition at line 438 of file InstrProfReader.h.

◆ getTemporalProfTraces()

template<class IntPtrT>
SmallVector< TemporalProfTraceTy > & RawInstrProfReader::getTemporalProfTraces ( std::optional< uint64_t > Weight = {})
overridevirtual
Parameters
Weightfor raw profiles use this as the temporal profile trace weight
Returns
a list of temporal profile traces.

Reimplemented from llvm::InstrProfReader.

Definition at line 484 of file InstrProfReader.cpp.

References assert(), and llvm::InstrProfReader::TemporalProfTraces.

◆ getVersion()

template<class IntPtrT>
uint64_t llvm::RawInstrProfReader< IntPtrT >::getVersion ( ) const
inlineoverridevirtual

Return the profile version.

Implements llvm::InstrProfReader.

Definition at line 399 of file InstrProfReader.h.

◆ hasCSIRLevelProfile()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::hasCSIRLevelProfile ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 405 of file InstrProfReader.h.

◆ hasFormat()

template<class IntPtrT>
bool RawInstrProfReader::hasFormat ( const MemoryBuffer & DataBuffer)
static

Definition at line 502 of file InstrProfReader.cpp.

References llvm::byteswap(), and llvm::RawInstrProf::getMagic().

Referenced by readHeader().

◆ hasMemoryProfile()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::hasMemoryProfile ( ) const
inlineoverridevirtual

Return true if profile includes a memory profile.

Implements llvm::InstrProfReader.

Definition at line 425 of file InstrProfReader.h.

◆ hasSingleByteCoverage()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::hasSingleByteCoverage ( ) const
inlineoverridevirtual

Return true if the profile has single byte counters representing coverage.

Implements llvm::InstrProfReader.

Definition at line 417 of file InstrProfReader.h.

◆ hasTemporalProfile()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::hasTemporalProfile ( ) const
inlineoverridevirtual

Return true if this has a temporal profile.

Implements llvm::InstrProfReader.

Definition at line 431 of file InstrProfReader.h.

◆ instrEntryBBEnabled()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::instrEntryBBEnabled ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 409 of file InstrProfReader.h.

◆ instrLoopEntriesEnabled()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::instrLoopEntriesEnabled ( ) const
inlineoverridevirtual

Return true if the profile instruments all loop entries.

Implements llvm::InstrProfReader.

Definition at line 413 of file InstrProfReader.h.

◆ isIRLevelProfile()

template<class IntPtrT>
bool llvm::RawInstrProfReader< IntPtrT >::isIRLevelProfile ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 401 of file InstrProfReader.h.

◆ operator=()

◆ printBinaryIds()

template<class IntPtrT>
Error RawInstrProfReader::printBinaryIds ( raw_ostream & OS)
overridevirtual

Print binary ids.

Reimplemented from llvm::InstrProfReader.

Definition at line 902 of file InstrProfReader.cpp.

References printBinaryIdsInternal(), and llvm::Error::success().

◆ readBinaryIds()

template<class IntPtrT>
Error RawInstrProfReader::readBinaryIds ( std::vector< llvm::object::BuildID > & BinaryIds)
overridevirtual

Read a list of binary ids.

Reimplemented from llvm::InstrProfReader.

Definition at line 894 of file InstrProfReader.cpp.

References llvm::Error::success().

◆ readHeader()

template<class IntPtrT>
Error RawInstrProfReader::readHeader ( )
overridevirtual

Read the header. Required before reading first record.

Implements llvm::InstrProfReader.

Definition at line 512 of file InstrProfReader.cpp.

References llvm::bad_header, llvm::bad_magic, error, llvm::RawInstrProf::getMagic(), hasFormat(), and readHeader().

Referenced by readHeader().

◆ readNextRecord()

template<class IntPtrT>
Error RawInstrProfReader::readNextRecord ( NamedInstrProfRecord & Record)
overridevirtual

Read a single record.

Implements llvm::InstrProfReader.

Definition at line 860 of file InstrProfReader.cpp.

References error, and llvm::success.


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