LLVM
17.0.0git
|
Reader for the indexed binary instrprof format. More...
#include "llvm/ProfileData/InstrProfReader.h"
Public Member Functions | |
IndexedInstrProfReader (std::unique_ptr< MemoryBuffer > DataBuffer, std::unique_ptr< MemoryBuffer > RemappingBuffer=nullptr) | |
IndexedInstrProfReader (const IndexedInstrProfReader &)=delete | |
IndexedInstrProfReader & | operator= (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< InstrProfRecord > | getInstrProfRecord (StringRef FuncName, uint64_t FuncHash, uint64_t *MismatchedFuncSum=nullptr) |
Return the NamedInstrProfRecord associated with FuncName and FuncHash. More... | |
Expected< memprof::MemProfRecord > | getMemProfRecord (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) |
InstrProfSymtab & | getSymtab () override |
Return the PGO symtab. More... | |
ProfileSummary & | getSummary (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... | |
![]() | |
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 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 | |
![]() | |
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... | |
![]() | |
std::unique_ptr< InstrProfSymtab > | Symtab |
Reader for the indexed binary instrprof format.
Definition at line 589 of file InstrProfReader.h.
|
inline |
Definition at line 624 of file InstrProfReader.h.
|
delete |
|
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().
|
static |
Definition at line 225 of file InstrProfReader.cpp.
References llvm::bad_magic, E, hasFormat(), initializeReader(), llvm::max(), move, and llvm::too_large.
|
inlineoverridevirtual |
Return true if the profile only instruments function entries.
Implements llvm::InstrProfReader.
Definition at line 647 of file InstrProfReader.h.
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.
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.
|
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().
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.
|
inlineoverridevirtual |
Returns a BitsetEnum describing the attributes of the indexed instr profile.
Implements llvm::InstrProfReader.
Definition at line 653 of file InstrProfReader.h.
|
inline |
Return the profile summary.
UseCS
indicates whether to use the context-sensitive summary.
Definition at line 714 of file InstrProfReader.h.
References assert().
|
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().
|
inlineoverridevirtual |
Return the profile version.
Implements llvm::InstrProfReader.
Definition at line 633 of file InstrProfReader.h.
|
inlineoverridevirtual |
Implements llvm::InstrProfReader.
Definition at line 635 of file InstrProfReader.h.
|
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().
|
inlineoverridevirtual |
Return true if profile includes a memory profile.
Implements llvm::InstrProfReader.
Definition at line 649 of file InstrProfReader.h.
|
inlineoverridevirtual |
Return true if the profile has single byte counters representing coverage.
Implements llvm::InstrProfReader.
Definition at line 643 of file InstrProfReader.h.
|
inlineoverridevirtual |
Implements llvm::InstrProfReader.
Definition at line 639 of file InstrProfReader.h.
|
inlineoverridevirtual |
Implements llvm::InstrProfReader.
Definition at line 634 of file InstrProfReader.h.
|
delete |
|
overridevirtual |
Print binary ids.
Reimplemented from llvm::InstrProfReader.
Definition at line 1211 of file InstrProfReader.cpp.
References llvm::support::little, and printBinaryIdsInternal().
|
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().
|
overridevirtual |
Read the file header.
Implements llvm::InstrProfReader.
Definition at line 980 of file InstrProfReader.cpp.
References llvm::bad_header, llvm::OnDiskIterableChainedHashTable< Info >::Create(), E, error, llvm::IndexedInstrProf::Last, llvm::malformed, move, Ptr, llvm::IndexedInstrProf::Header::readFromBuffer(), llvm::memprof::readMemProfSchema(), support(), llvm::truncated, and llvm::unsupported_hash_type.
|
overridevirtual |
Read a single record.
Implements llvm::InstrProfReader.
Definition at line 1190 of file InstrProfReader.cpp.
References llvm::Data, E, error, and move.
|
inline |
Definition at line 703 of file InstrProfReader.h.
References llvm::msgpack::Endianness.