LLVM
15.0.0git
|
#include "llvm/ProfileData/SampleProfReader.h"
Public Member Functions | |
SampleProfileReaderBinary (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None) | |
virtual std::error_code | readHeader () override |
Read and validate the file header. More... | |
std::error_code | readImpl () override |
Read sample profiles from the associated file. More... | |
virtual std::vector< StringRef > * | getNameTable () override |
It includes all the names that have samples either in outline instance or inline instance. More... | |
![]() | |
SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None) | |
virtual | ~SampleProfileReader ()=default |
void | setDiscriminatorMaskedBitFrom (FSDiscriminatorPass P) |
Set the bits for FS discriminators. More... | |
uint32_t | getDiscriminatorMask () const |
Get the bitmask the discriminators: For FS profiles, return the bit mask for this pass. More... | |
std::error_code | read () |
The interface to read sample profiles from the associated file. More... | |
void | dumpFunctionProfile (SampleContext FContext, raw_ostream &OS=dbgs()) |
Print the profile for FContext on stream OS . More... | |
virtual bool | collectFuncsFromModule () |
Collect functions with definitions in Module M. More... | |
void | dump (raw_ostream &OS=dbgs()) |
Print all the profiles on stream OS . More... | |
FunctionSamples * | getSamplesFor (const Function &F) |
Return the samples collected for function F . More... | |
FunctionSamples * | getOrCreateSamplesFor (const Function &F) |
Return the samples collected for function F , create empty FunctionSamples if it doesn't exist. More... | |
virtual FunctionSamples * | getSamplesFor (StringRef Fname) |
Return the samples collected for function F . More... | |
SampleProfileMap & | getProfiles () |
Return all the profiles. More... | |
void | reportError (int64_t LineNumber, const Twine &Msg) const |
Report a parse error message. More... | |
ProfileSummary & | getSummary () const |
Return the profile summary. More... | |
MemoryBuffer * | getBuffer () const |
SampleProfileFormat | getFormat () const |
Return the profile format. More... | |
bool | profileIsProbeBased () const |
Whether input profile is based on pseudo probes. More... | |
bool | profileIsCS () const |
Whether input profile is fully context-sensitive. More... | |
bool | profileIsPreInlined () const |
Whether input profile contains ShouldBeInlined contexts. More... | |
virtual std::unique_ptr< ProfileSymbolList > | getProfileSymbolList () |
virtual bool | dumpSectionInfo (raw_ostream &OS=dbgs()) |
virtual bool | useMD5 () |
Return whether names in the profile are all MD5 numbers. More... | |
virtual void | setSkipFlatProf (bool Skip) |
Don't read profile without context if the flag is set. More... | |
virtual bool | hasUniqSuffix () |
Return whether any name in the profile contains ".__uniq." suffix. More... | |
SampleProfileReaderItaniumRemapper * | getRemapper () |
void | setModule (const Module *Mod) |
Protected Member Functions | |
template<typename T > | |
ErrorOr< T > | readNumber () |
Read a numeric value of type T from the profile. More... | |
template<typename T > | |
ErrorOr< T > | readUnencodedNumber () |
Read a numeric value of type T from the profile. More... | |
ErrorOr< StringRef > | readString () |
Read a string from the profile. More... | |
template<typename T > | |
ErrorOr< uint32_t > | readStringIndex (T &Table) |
Read the string index and check whether it overflows the table. More... | |
bool | at_eof () const |
Return true if we've reached the end of file. More... | |
std::error_code | readFuncProfile (const uint8_t *Start) |
Read the next function profile instance. More... | |
std::error_code | readProfile (FunctionSamples &FProfile) |
Read the contents of the given profile instance. More... | |
std::error_code | readMagicIdent () |
Read the contents of Magic number and Version number. More... | |
std::error_code | readSummary () |
Read profile summary. More... | |
virtual std::error_code | readNameTable () |
Read the whole name table. More... | |
virtual ErrorOr< StringRef > | readStringFromTable () |
Read a string indirectly via the name table. More... | |
virtual ErrorOr< SampleContext > | readSampleContextFromTable () |
![]() | |
void | computeSummary () |
Compute summary for this profile. More... | |
Protected Attributes | |
const uint8_t * | Data = nullptr |
Points to the current location in the buffer. More... | |
const uint8_t * | End = nullptr |
Points to the end of the buffer. More... | |
std::vector< StringRef > | NameTable |
Function name table. More... | |
![]() | |
SampleProfileMap | Profiles |
Map every function to its associated profile. More... | |
LLVMContext & | Ctx |
LLVM context used to emit diagnostics. More... | |
std::unique_ptr< MemoryBuffer > | Buffer |
Memory buffer holding the profile file. More... | |
std::unordered_set< std::string > | MD5NameBuffer |
Extra name buffer holding names created on demand. More... | |
std::unique_ptr< ProfileSummary > | Summary |
Profile summary information. More... | |
std::unique_ptr< SampleProfileReaderItaniumRemapper > | Remapper |
bool | ProfileIsProbeBased = false |
Whether samples are collected based on pseudo probes. More... | |
bool | ProfileIsCS = false |
Whether function profiles are context-sensitive flat profiles. More... | |
bool | ProfileIsPreInlined = false |
Whether function profile contains ShouldBeInlined contexts. More... | |
uint32_t | CSProfileCount = 0 |
Number of context-sensitive profiles. More... | |
bool | ProfileIsFS = false |
Whether the function profiles use FS discriminators. More... | |
SampleProfileFormat | Format = SPF_None |
The format of sample. More... | |
const Module * | M = nullptr |
The current module being compiled if SampleProfileReader is used by compiler. More... | |
uint32_t | MaskedBitFrom = 31 |
Zero out the discriminator bits higher than bit MaskedBitFrom (0 based). More... | |
Additional Inherited Members | |
![]() | |
static ErrorOr< std::unique_ptr< SampleProfileReader > > | create (const std::string Filename, LLVMContext &C, FSDiscriminatorPass P=FSDiscriminatorPass::Base, const std::string RemapFilename="") |
Create a sample profile reader appropriate to the file format. More... | |
static ErrorOr< std::unique_ptr< SampleProfileReader > > | create (std::unique_ptr< MemoryBuffer > &B, LLVMContext &C, FSDiscriminatorPass P=FSDiscriminatorPass::Base, const std::string RemapFilename="") |
Create a sample profile reader from the supplied memory buffer. More... | |
![]() | |
static std::unique_ptr< ProfileSummary > | takeSummary (SampleProfileReader &Reader) |
Take ownership of the summary of this reader. More... | |
Definition at line 581 of file SampleProfReader.h.
|
inline |
Definition at line 583 of file SampleProfReader.h.
|
inlineprotected |
Return true if we've reached the end of file.
Definition at line 622 of file SampleProfReader.h.
Referenced by readImpl().
|
inlineoverridevirtual |
It includes all the names that have samples either in outline instance or inline instance.
Reimplemented from llvm::sampleprof::SampleProfileReader.
Definition at line 595 of file SampleProfReader.h.
References NameTable.
|
protected |
Read the next function profile instance.
Definition at line 587 of file SampleProfReader.cpp.
References llvm::sampleprof::FunctionSamples::addHeadSamples(), llvm::sampleprof::SampleProfileReader::CSProfileCount, Data, llvm::ErrorOr< T >::getError(), llvm::sampleprof::SampleProfileReader::Profiles, readProfile(), readSampleContextFromTable(), llvm::sampleprof::FunctionSamples::setContext(), and llvm::success.
Referenced by llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncProfiles(), readImpl(), and llvm::sampleprof::SampleProfileReaderCompactBinary::readImpl().
|
overridevirtual |
Read and validate the file header.
Implements llvm::sampleprof::SampleProfileReader.
Reimplemented in llvm::sampleprof::SampleProfileReaderExtBinaryBase.
Definition at line 1341 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReader::Buffer, Data, End, readMagicIdent(), readNameTable(), readSummary(), and llvm::success.
|
overridevirtual |
Read sample profiles from the associated file.
Implements llvm::sampleprof::SampleProfileReader.
Reimplemented in llvm::sampleprof::SampleProfileReaderCompactBinary, and llvm::sampleprof::SampleProfileReaderExtBinaryBase.
Definition at line 610 of file SampleProfReader.cpp.
References at_eof(), Data, llvm::sampleprof::SampleProfileReader::ProfileIsFS, llvm::sampleprof::FunctionSamples::ProfileIsFS, ProfileIsFSDisciminator, readFuncProfile(), and llvm::success.
|
protected |
Read the contents of Magic number and Version number.
Definition at line 1323 of file SampleProfReader.cpp.
References llvm::msf::Magic, llvm::sampleprof::SPVersion(), llvm::success, llvm::unsupported_version, and Version.
Referenced by readHeader(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readHeader().
|
protectedvirtual |
Read the whole name table.
Definition at line 994 of file SampleProfReader.cpp.
References I, NameTable, readString(), and llvm::success.
Referenced by readHeader(), llvm::sampleprof::SampleProfileReaderGCC::readImpl(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readNameTableSec().
Read a numeric value of type T from the profile.
If an error occurs during decoding, a diagnostic message is emitted and EC is set.
Definition at line 392 of file SampleProfReader.cpp.
References Data, llvm::decodeULEB128(), End, llvm::malformed, llvm::max(), llvm::sampleprof::SampleProfileReader::reportError(), llvm::success, and llvm::truncated.
|
protected |
Read the contents of the given profile instance.
Definition at line 504 of file SampleProfReader.cpp.
References llvm::sampleprof::FunctionSamples::addBodySamples(), llvm::sampleprof::FunctionSamples::addCalledTargetSamples(), llvm::sampleprof::FunctionSamples::addTotalSamples(), llvm::sampleprof::FunctionSamples::functionSamplesAt(), llvm::sampleprof::SampleProfileReader::getDiscriminatorMask(), I, isOffsetLegal(), readStringFromTable(), llvm::sampleprof::FunctionSamples::setName(), and llvm::success.
Referenced by readFuncProfile().
|
protectedvirtual |
Reimplemented in llvm::sampleprof::SampleProfileReaderExtBinaryBase.
Definition at line 460 of file SampleProfReader.cpp.
References readStringFromTable().
Referenced by llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncMetadata(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncOffsetTable(), and readFuncProfile().
Read a string from the profile.
If an error occurs during decoding, a diagnostic message is emitted and EC is set.
Definition at line 413 of file SampleProfReader.cpp.
References Data, End, llvm::sampleprof::SampleProfileReader::reportError(), and llvm::truncated.
Referenced by readNameTable().
Read a string indirectly via the name table.
Reimplemented in llvm::sampleprof::SampleProfileReaderExtBinaryBase.
Definition at line 452 of file SampleProfReader.cpp.
References NameTable, and readStringIndex().
Referenced by llvm::sampleprof::SampleProfileReaderExtBinaryBase::readCSNameTableSec(), readProfile(), readSampleContextFromTable(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readSampleContextFromTable(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readStringFromTable().
|
inlineprotected |
Read the string index and check whether it overflows the table.
Definition at line 442 of file SampleProfReader.cpp.
References llvm::truncated_name_table.
Referenced by readStringFromTable(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readStringFromTable().
|
protected |
Read profile summary.
Definition at line 1422 of file SampleProfReader.cpp.
Referenced by readHeader().
Read a numeric value of type T from the profile.
The value is saved without encoded.
Definition at line 427 of file SampleProfReader.cpp.
References Data, End, llvm::sampleprof::SampleProfileReader::reportError(), support(), and llvm::truncated.
|
protected |
Points to the current location in the buffer.
Definition at line 640 of file SampleProfReader.h.
Referenced by at_eof(), llvm::sampleprof::SampleProfileReaderRawBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderExtBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderCompactBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncMetadata(), readFuncProfile(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncProfiles(), readHeader(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readHeader(), readImpl(), llvm::sampleprof::SampleProfileReaderCompactBinary::readImpl(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readMD5NameTable(), readNumber(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readProfileSymbolList(), readString(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readStringFromTable(), and readUnencodedNumber().
|
protected |
Points to the end of the buffer.
Definition at line 643 of file SampleProfReader.h.
Referenced by at_eof(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncMetadata(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncProfiles(), readHeader(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readHeader(), readNumber(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readProfileSymbolList(), readString(), and readUnencodedNumber().
|
protected |
Function name table.
Definition at line 646 of file SampleProfReader.h.
Referenced by getNameTable(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readMD5NameTable(), readNameTable(), readStringFromTable(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readStringFromTable().