LLVM 19.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::InstrProfReader Class Referenceabstract

Base class and interface for reading profiling data of any known instrprof format. More...

#include "llvm/ProfileData/InstrProfReader.h"

Inheritance diagram for llvm::InstrProfReader:
Inheritance graph
[legend]

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 InstrProfSymtabgetSymtab ()=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< InstrProfSymtabSymtab
 
SmallVector< TemporalProfTraceTyTemporalProfTraces
 A list of temporal profile traces.
 
uint64_t TemporalProfTraceStreamSize = 0
 The total number of temporal profile traces seen.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ InstrProfReader()

llvm::InstrProfReader::InstrProfReader ( )
default

◆ ~InstrProfReader()

virtual llvm::InstrProfReader::~InstrProfReader ( )
virtualdefault

Member Function Documentation

◆ accumulateCounts()

void InstrProfReader::accumulateCounts ( CountSumOrPercent Sum,
bool  IsCS 
)

Compute the sum of counts and return in Sum.

Definition at line 1542 of file InstrProfReader.cpp.

References llvm::NamedInstrProfRecord::hasCSFlagInHash(), isIRLevelProfile(), and llvm::CountSumOrPercent::NumEntries.

◆ begin()

InstrProfIterator llvm::InstrProfReader::begin ( )
inline

Iterator over profile data.

Definition at line 114 of file InstrProfReader.h.

◆ create() [1/2]

Expected< std::unique_ptr< InstrProfReader > > InstrProfReader::create ( const Twine Path,
vfs::FileSystem FS,
const InstrProfCorrelator Correlator = nullptr,
std::function< void(Error)>  Warn = nullptr 
)
static

Factory method to create an appropriately typed reader for the given instrprof file.

Definition at line 157 of file InstrProfReader.cpp.

References create(), and setupMemoryBuffer().

Referenced by llvm::OverlapStats::accumulateCounts(), and create().

◆ create() [2/2]

Expected< std::unique_ptr< InstrProfReader > > InstrProfReader::create ( std::unique_ptr< MemoryBuffer Buffer,
const InstrProfCorrelator Correlator = nullptr,
std::function< void(Error)>  Warn = nullptr 
)
static

◆ end()

InstrProfIterator llvm::InstrProfReader::end ( )
inline

Definition at line 115 of file InstrProfReader.h.

◆ error() [1/2]

Error llvm::InstrProfReader::error ( Error &&  E)
inlineprotected

◆ error() [2/2]

Error llvm::InstrProfReader::error ( instrprof_error  Err,
const std::string &  ErrMsg = "" 
)
inlineprotected

Set the current error and return same.

Definition at line 165 of file InstrProfReader.h.

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

◆ functionEntryOnly()

virtual bool llvm::InstrProfReader::functionEntryOnly ( ) const
pure virtual

Return true if the profile only instruments function entries.

Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

◆ getError()

Error llvm::InstrProfReader::getError ( )
inline

Get the current error.

Definition at line 192 of file InstrProfReader.h.

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

◆ getProfileKind()

virtual InstrProfKind llvm::InstrProfReader::getProfileKind ( ) const
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.

◆ getSymtab()

virtual InstrProfSymtab & llvm::InstrProfReader::getSymtab ( )
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.

◆ getTemporalProfTraces()

virtual SmallVector< TemporalProfTraceTy > & llvm::InstrProfReader::getTemporalProfTraces ( std::optional< uint64_t Weight = {})
inlinevirtual
Parameters
Weightfor raw profiles use this as the temporal profile trace weight
Returns
a list of temporal profile traces.

Reimplemented in llvm::RawInstrProfReader< IntPtrT >.

Definition at line 214 of file InstrProfReader.h.

◆ getTemporalProfTraceStreamSize()

uint64_t llvm::InstrProfReader::getTemporalProfTraceStreamSize ( )
inline
Returns
the total number of temporal profile traces seen.

Definition at line 220 of file InstrProfReader.h.

References TemporalProfTraceStreamSize.

◆ getVersion()

virtual uint64_t llvm::InstrProfReader::getVersion ( ) const
pure virtual

◆ hasCSIRLevelProfile()

virtual bool llvm::InstrProfReader::hasCSIRLevelProfile ( ) const
pure virtual

◆ hasError()

bool llvm::InstrProfReader::hasError ( )
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().

◆ hasMemoryProfile()

virtual bool llvm::InstrProfReader::hasMemoryProfile ( ) const
pure virtual

Return true if profile includes a memory profile.

Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

◆ hasSingleByteCoverage()

virtual bool llvm::InstrProfReader::hasSingleByteCoverage ( ) const
pure virtual

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

Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

◆ hasTemporalProfile()

virtual bool llvm::InstrProfReader::hasTemporalProfile ( ) const
pure virtual

Return true if this has a temporal profile.

Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

◆ instrEntryBBEnabled()

virtual bool llvm::InstrProfReader::instrEntryBBEnabled ( ) const
pure virtual

◆ isEOF()

bool llvm::InstrProfReader::isEOF ( )
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().

◆ isIRLevelProfile()

virtual bool llvm::InstrProfReader::isIRLevelProfile ( ) const
pure virtual

◆ printBinaryIds()

virtual Error llvm::InstrProfReader::printBinaryIds ( raw_ostream OS)
inlinevirtual

Print binary ids.

Reimplemented in llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

Definition at line 111 of file InstrProfReader.h.

References success().

◆ readBinaryIds()

virtual Error llvm::InstrProfReader::readBinaryIds ( std::vector< llvm::object::BuildID > &  BinaryIds)
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().

◆ readHeader()

virtual Error llvm::InstrProfReader::readHeader ( )
pure virtual

Read the header. Required before reading first record.

Implemented in llvm::TextInstrProfReader, llvm::RawInstrProfReader< IntPtrT >, and llvm::IndexedInstrProfReader.

Referenced by initializeReader().

◆ readNextRecord()

virtual Error llvm::InstrProfReader::readNextRecord ( NamedInstrProfRecord Record)
pure virtual

◆ success()

Error llvm::InstrProfReader::success ( )
inlineprotected

Member Data Documentation

◆ Symtab

std::unique_ptr<InstrProfSymtab> llvm::InstrProfReader::Symtab
protected

◆ TemporalProfTraces

SmallVector<TemporalProfTraceTy> llvm::InstrProfReader::TemporalProfTraces
protected

A list of temporal profile traces.

Definition at line 160 of file InstrProfReader.h.

Referenced by llvm::IndexedInstrProfReader::readHeader().

◆ TemporalProfTraceStreamSize

uint64_t llvm::InstrProfReader::TemporalProfTraceStreamSize = 0
protected

The total number of temporal profile traces seen.

Definition at line 162 of file InstrProfReader.h.

Referenced by getTemporalProfTraceStreamSize(), and llvm::IndexedInstrProfReader::readHeader().


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