LLVM  17.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::IndexedInstrProfReader Class Reference

Reader for the indexed binary instrprof format. More...

#include "llvm/ProfileData/InstrProfReader.h"

Inheritance diagram for llvm::IndexedInstrProfReader:
Inheritance graph
[legend]
Collaboration diagram for llvm::IndexedInstrProfReader:
Collaboration graph
[legend]

Public Member Functions

 IndexedInstrProfReader (std::unique_ptr< MemoryBuffer > DataBuffer, std::unique_ptr< MemoryBuffer > RemappingBuffer=nullptr)
 
 IndexedInstrProfReader (const IndexedInstrProfReader &)=delete
 
IndexedInstrProfReaderoperator= (const IndexedInstrProfReader &)=delete
 
uint64_t getVersion () const override
 Return the profile version. More...
 
bool isIRLevelProfile () const override
 
bool hasCSIRLevelProfile () const override
 
bool instrEntryBBEnabled () const override
 
bool hasSingleByteCoverage () const override
 Return true if the profile has single byte counters representing coverage. More...
 
bool functionEntryOnly () const override
 Return true if the profile only instruments function entries. More...
 
bool hasMemoryProfile () const override
 Return true if profile includes a memory profile. More...
 
InstrProfKind getProfileKind () const override
 Returns a BitsetEnum describing the attributes of the indexed instr profile. More...
 
Error readHeader () override
 Read the file header. More...
 
Error readNextRecord (NamedInstrProfRecord &Record) override
 Read a single record. More...
 
Expected< InstrProfRecordgetInstrProfRecord (StringRef FuncName, uint64_t FuncHash, uint64_t *MismatchedFuncSum=nullptr)
 Return the NamedInstrProfRecord associated with FuncName and FuncHash. More...
 
Expected< memprof::MemProfRecordgetMemProfRecord (uint64_t FuncNameHash)
 Return the memprof record for the function identified by llvm::md5(Name). More...
 
Error getFunctionCounts (StringRef FuncName, uint64_t FuncHash, std::vector< uint64_t > &Counts)
 Fill Counts with the profile data for the given function name. More...
 
uint64_t getMaximumFunctionCount (bool UseCS)
 Return the maximum of all known function counts. More...
 
void setValueProfDataEndianness (support::endianness Endianness)
 
InstrProfSymtabgetSymtab () override
 Return the PGO symtab. More...
 
ProfileSummarygetSummary (bool UseCS)
 Return the profile summary. More...
 
Error readBinaryIds (std::vector< llvm::object::BuildID > &BinaryIds) override
 Read a list of binary ids. More...
 
Error printBinaryIds (raw_ostream &OS) override
 Print binary ids. More...
 
- Public Member Functions inherited from llvm::InstrProfReader
 InstrProfReader ()=default
 
virtual ~InstrProfReader ()=default
 
InstrProfIterator begin ()
 Iterator over profile data. More...
 
InstrProfIterator end ()
 
virtual bool useDebugInfoCorrelate () const
 Return true if we must provide debug info to create PGO profiles. More...
 
void accumulateCounts (CountSumOrPercent &Sum, bool IsCS)
 Compute the sum of counts and return in Sum. More...
 
bool isEOF ()
 Return true if the reader has finished reading the profile data. More...
 
bool hasError ()
 Return true if the reader encountered an error reading profiling data. More...
 
Error getError ()
 Get the current error. More...
 

Static Public Member Functions

static bool hasFormat (const MemoryBuffer &DataBuffer)
 Return true if the given buffer is in an indexed instrprof format. More...
 
static Expected< std::unique_ptr< IndexedInstrProfReader > > create (const Twine &Path, const Twine &RemappingPath="")
 Factory method to create an indexed reader. More...
 
static Expected< std::unique_ptr< IndexedInstrProfReader > > create (std::unique_ptr< MemoryBuffer > Buffer, std::unique_ptr< MemoryBuffer > RemappingBuffer=nullptr)
 
- Static Public Member Functions inherited from llvm::InstrProfReader
static Expected< std::unique_ptr< InstrProfReader > > create (const Twine &Path, const InstrProfCorrelator *Correlator=nullptr)
 Factory method to create an appropriately typed reader for the given instrprof file. More...
 
static Expected< std::unique_ptr< InstrProfReader > > create (std::unique_ptr< MemoryBuffer > Buffer, const InstrProfCorrelator *Correlator=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. More...
 
Error error (Error &&E)
 
Error success ()
 Clear the current error and return a successful one. More...
 
- Protected Attributes inherited from llvm::InstrProfReader
std::unique_ptr< InstrProfSymtabSymtab
 

Detailed Description

Reader for the indexed binary instrprof format.

Definition at line 589 of file InstrProfReader.h.

Constructor & Destructor Documentation

◆ IndexedInstrProfReader() [1/2]

llvm::IndexedInstrProfReader::IndexedInstrProfReader ( std::unique_ptr< MemoryBuffer DataBuffer,
std::unique_ptr< MemoryBuffer RemappingBuffer = nullptr 
)
inline

Definition at line 624 of file InstrProfReader.h.

◆ IndexedInstrProfReader() [2/2]

llvm::IndexedInstrProfReader::IndexedInstrProfReader ( const IndexedInstrProfReader )
delete

Member Function Documentation

◆ create() [1/2]

Expected< std::unique_ptr< IndexedInstrProfReader > > IndexedInstrProfReader::create ( const Twine Path,
const Twine RemappingPath = "" 
)
static

Factory method to create an indexed reader.

Definition at line 204 of file InstrProfReader.cpp.

References E, move, setupMemoryBuffer(), and llvm::Twine::str().

Referenced by annotateAllFunctions(), and llvm::coverage::CoverageMapping::load().

◆ create() [2/2]

Expected< std::unique_ptr< IndexedInstrProfReader > > IndexedInstrProfReader::create ( std::unique_ptr< MemoryBuffer Buffer,
std::unique_ptr< MemoryBuffer RemappingBuffer = nullptr 
)
static

◆ functionEntryOnly()

bool llvm::IndexedInstrProfReader::functionEntryOnly ( ) const
inlineoverridevirtual

Return true if the profile only instruments function entries.

Implements llvm::InstrProfReader.

Definition at line 647 of file InstrProfReader.h.

◆ getFunctionCounts()

Error IndexedInstrProfReader::getFunctionCounts ( StringRef  FuncName,
uint64_t  FuncHash,
std::vector< uint64_t > &  Counts 
)

Fill Counts with the profile data for the given function name.

Definition at line 1179 of file InstrProfReader.cpp.

References E, error, and move.

◆ getInstrProfRecord()

Expected< InstrProfRecord > IndexedInstrProfReader::getInstrProfRecord ( StringRef  FuncName,
uint64_t  FuncHash,
uint64_t MismatchedFuncSum = nullptr 
)

Return the NamedInstrProfRecord associated with FuncName and FuncHash.

When return a hash_mismatch error and MismatchedFuncSum is not nullptr, the sum of all counters in the mismatched function will be set to MismatchedFuncSum. If there are multiple instances of mismatched functions, MismatchedFuncSum returns the maximum.

Definition at line 1097 of file InstrProfReader.cpp.

References llvm::Data.

◆ getMaximumFunctionCount()

uint64_t llvm::IndexedInstrProfReader::getMaximumFunctionCount ( bool  UseCS)
inline

Return the maximum of all known function counts.

UseCS indicates whether to use the context-sensitive count.

Definition at line 684 of file InstrProfReader.h.

References assert().

◆ getMemProfRecord()

Expected< memprof::MemProfRecord > IndexedInstrProfReader::getMemProfRecord ( uint64_t  FuncNameHash)

Return the memprof record for the function identified by llvm::md5(Name).

Definition at line 1143 of file InstrProfReader.cpp.

References llvm::hash_mismatch, llvm::invalid_prof, and llvm::unknown_function.

◆ getProfileKind()

InstrProfKind llvm::IndexedInstrProfReader::getProfileKind ( ) const
inlineoverridevirtual

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

Implements llvm::InstrProfReader.

Definition at line 653 of file InstrProfReader.h.

◆ getSummary()

ProfileSummary& llvm::IndexedInstrProfReader::getSummary ( bool  UseCS)
inline

Return the profile summary.

UseCS indicates whether to use the context-sensitive summary.

Definition at line 714 of file InstrProfReader.h.

References assert().

◆ getSymtab()

InstrProfSymtab & IndexedInstrProfReader::getSymtab ( )
overridevirtual

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 1084 of file InstrProfReader.cpp.

References llvm::consumeError(), E, error, move, and llvm::InstrProfError::take().

◆ getVersion()

uint64_t llvm::IndexedInstrProfReader::getVersion ( ) const
inlineoverridevirtual

Return the profile version.

Implements llvm::InstrProfReader.

Definition at line 633 of file InstrProfReader.h.

◆ hasCSIRLevelProfile()

bool llvm::IndexedInstrProfReader::hasCSIRLevelProfile ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 635 of file InstrProfReader.h.

◆ hasFormat()

bool IndexedInstrProfReader::hasFormat ( const MemoryBuffer DataBuffer)
static

Return true if the given buffer is in an indexed instrprof format.

Definition at line 915 of file InstrProfReader.cpp.

References llvm::MemoryBuffer::getBufferSize(), llvm::MemoryBuffer::getBufferStart(), llvm::msf::Magic, llvm::IndexedInstrProf::Magic, and support().

Referenced by llvm::InstrProfReader::create(), and create().

◆ hasMemoryProfile()

bool llvm::IndexedInstrProfReader::hasMemoryProfile ( ) const
inlineoverridevirtual

Return true if profile includes a memory profile.

Implements llvm::InstrProfReader.

Definition at line 649 of file InstrProfReader.h.

◆ hasSingleByteCoverage()

bool llvm::IndexedInstrProfReader::hasSingleByteCoverage ( ) const
inlineoverridevirtual

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

Implements llvm::InstrProfReader.

Definition at line 643 of file InstrProfReader.h.

◆ instrEntryBBEnabled()

bool llvm::IndexedInstrProfReader::instrEntryBBEnabled ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 639 of file InstrProfReader.h.

◆ isIRLevelProfile()

bool llvm::IndexedInstrProfReader::isIRLevelProfile ( ) const
inlineoverridevirtual

Implements llvm::InstrProfReader.

Definition at line 634 of file InstrProfReader.h.

◆ operator=()

IndexedInstrProfReader& llvm::IndexedInstrProfReader::operator= ( const IndexedInstrProfReader )
delete

◆ printBinaryIds()

Error IndexedInstrProfReader::printBinaryIds ( raw_ostream OS)
overridevirtual

Print binary ids.

Reimplemented from llvm::InstrProfReader.

Definition at line 1211 of file InstrProfReader.cpp.

References llvm::support::little, and printBinaryIdsInternal().

◆ readBinaryIds()

Error IndexedInstrProfReader::readBinaryIds ( std::vector< llvm::object::BuildID > &  BinaryIds)
overridevirtual

Read a list of binary ids.

Reimplemented from llvm::InstrProfReader.

Definition at line 1205 of file InstrProfReader.cpp.

References llvm::support::little, and readBinaryIdsInternal().

◆ readHeader()

Error IndexedInstrProfReader::readHeader ( )
overridevirtual

◆ readNextRecord()

Error IndexedInstrProfReader::readNextRecord ( NamedInstrProfRecord Record)
overridevirtual

Read a single record.

Implements llvm::InstrProfReader.

Definition at line 1190 of file InstrProfReader.cpp.

References llvm::Data, E, error, and move.

◆ setValueProfDataEndianness()

void llvm::IndexedInstrProfReader::setValueProfDataEndianness ( support::endianness  Endianness)
inline

Definition at line 703 of file InstrProfReader.h.

References llvm::msgpack::Endianness.


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