LLVM 20.0.0git
|
Base class and interface for reading profiling data of any known instrprof format. More...
#include "llvm/ProfileData/InstrProfReader.h"
Public Member Functions | |
InstrProfReader ()=default | |
virtual | ~InstrProfReader ()=default |
virtual Error | readHeader ()=0 |
Read the header. Required before reading first record. | |
virtual Error | readNextRecord (NamedInstrProfRecord &Record)=0 |
Read a single record. | |
virtual Error | readBinaryIds (std::vector< llvm::object::BuildID > &BinaryIds) |
Read a list of binary ids. | |
virtual Error | printBinaryIds (raw_ostream &OS) |
Print binary ids. | |
InstrProfIterator | begin () |
Iterator over profile data. | |
InstrProfIterator | end () |
virtual uint64_t | getVersion () const =0 |
Return the profile version. | |
virtual bool | isIRLevelProfile () const =0 |
virtual bool | hasCSIRLevelProfile () const =0 |
virtual bool | instrEntryBBEnabled () const =0 |
virtual bool | hasSingleByteCoverage () const =0 |
Return true if the profile has single byte counters representing coverage. | |
virtual bool | functionEntryOnly () const =0 |
Return true if the profile only instruments function entries. | |
virtual bool | hasMemoryProfile () const =0 |
Return true if profile includes a memory profile. | |
virtual bool | hasTemporalProfile () const =0 |
Return true if this has a temporal profile. | |
virtual InstrProfKind | getProfileKind () const =0 |
Returns a BitsetEnum describing the attributes of the profile. | |
virtual InstrProfSymtab & | getSymtab ()=0 |
Return the PGO symtab. | |
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. | |
virtual SmallVector< TemporalProfTraceTy > & | getTemporalProfTraces (std::optional< uint64_t > Weight={}) |
uint64_t | getTemporalProfTraceStreamSize () |
Static Public Member Functions | |
static Expected< std::unique_ptr< InstrProfReader > > | create (const Twine &Path, vfs::FileSystem &FS, const InstrProfCorrelator *Correlator=nullptr, std::function< void(Error)> Warn=nullptr) |
Factory method to create an appropriately typed reader for the given instrprof file. | |
static Expected< std::unique_ptr< InstrProfReader > > | create (std::unique_ptr< MemoryBuffer > Buffer, const InstrProfCorrelator *Correlator=nullptr, std::function< void(Error)> Warn=nullptr) |
Protected Member Functions | |
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 | |
std::unique_ptr< InstrProfSymtab > | Symtab |
SmallVector< TemporalProfTraceTy > | TemporalProfTraces |
A list of temporal profile traces. | |
uint64_t | TemporalProfTraceStreamSize = 0 |
The total number of temporal profile traces seen. | |
Base class and interface for reading profiling data of any known instrprof format.
Provides an iterator over NamedInstrProfRecords.
Definition at line 91 of file InstrProfReader.h.
|
default |
|
virtualdefault |
void InstrProfReader::accumulateCounts | ( | CountSumOrPercent & | Sum, |
bool | IsCS | ||
) |
Compute the sum of counts and return in Sum.
Definition at line 1708 of file InstrProfReader.cpp.
References llvm::NamedInstrProfRecord::hasCSFlagInHash(), isIRLevelProfile(), and llvm::CountSumOrPercent::NumEntries.
|
inline |
Iterator over profile data.
Definition at line 114 of file InstrProfReader.h.
|
static |
Factory method to create an appropriately typed reader for the given instrprof file.
Definition at line 154 of file InstrProfReader.cpp.
References create(), and llvm::setupMemoryBuffer().
Referenced by llvm::OverlapStats::accumulateCounts(), and create().
|
static |
Definition at line 166 of file InstrProfReader.cpp.
References llvm::empty_raw_profile, llvm::TextInstrProfReader::hasFormat(), llvm::RawInstrProfReader< IntPtrT >::hasFormat(), llvm::IndexedInstrProfReader::hasFormat(), initializeReader(), and llvm::unrecognized_format.
|
inline |
Definition at line 115 of file InstrProfReader.h.
Definition at line 173 of file InstrProfReader.h.
References E, llvm::InstrProfError::get(), llvm::InstrProfError::getMessage(), and llvm::handleAllErrors().
|
inlineprotected |
Set the current error and return same.
Definition at line 165 of file InstrProfReader.h.
References llvm::success, and llvm::Error::success().
|
pure virtual |
Return true if the profile only instruments function entries.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
inline |
Get the current error.
Definition at line 192 of file InstrProfReader.h.
References hasError(), and llvm::Error::success().
|
pure virtual |
Returns a BitsetEnum describing the attributes of the profile.
To check individual attributes prefer using the helpers above.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
pure virtual |
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.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
inlinevirtual |
Weight | for raw profiles use this as the temporal profile trace weight |
Reimplemented in llvm::RawInstrProfReader< IntPtrT >.
Definition at line 214 of file InstrProfReader.h.
|
inline |
Definition at line 220 of file InstrProfReader.h.
References TemporalProfTraceStreamSize.
|
pure virtual |
Return the profile version.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
pure virtual |
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
inline |
Return true if the reader encountered an error reading profiling data.
Definition at line 189 of file InstrProfReader.h.
References isEOF(), and llvm::success.
Referenced by getError().
|
pure virtual |
Return true if profile includes a memory profile.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
pure virtual |
Return true if the profile has single byte counters representing coverage.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
pure virtual |
Return true if this has a temporal profile.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
pure virtual |
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
inline |
Return true if the reader has finished reading the profile data.
Definition at line 186 of file InstrProfReader.h.
References llvm::eof.
Referenced by hasError().
|
pure virtual |
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
Referenced by accumulateCounts().
|
inlinevirtual |
Print binary ids.
Reimplemented in llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
Definition at line 111 of file InstrProfReader.h.
References success().
|
inlinevirtual |
Read a list of binary ids.
Reimplemented in llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
Definition at line 106 of file InstrProfReader.h.
References success().
|
pure virtual |
Read the header. Required before reading first record.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
Referenced by initializeReader().
|
pure virtual |
Read a single record.
Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.
|
inlineprotected |
Clear the current error and return a successful one.
Definition at line 182 of file InstrProfReader.h.
References error, and llvm::success.
Referenced by llvm::IndexedInstrProfReader::getFunctionBitmap(), llvm::IndexedInstrProfReader::getFunctionCounts(), printBinaryIds(), readBinaryIds(), llvm::TextInstrProfReader::readHeader(), llvm::IndexedInstrProfReader::readHeader(), llvm::TextInstrProfReader::readNextRecord(), and llvm::IndexedInstrProfReader::readNextRecord().
|
protected |
|
protected |
A list of temporal profile traces.
Definition at line 160 of file InstrProfReader.h.
Referenced by llvm::IndexedInstrProfReader::readHeader().
|
protected |
The total number of temporal profile traces seen.
Definition at line 162 of file InstrProfReader.h.
Referenced by getTemporalProfTraceStreamSize(), and llvm::IndexedInstrProfReader::readHeader().