LLVM
17.0.0git
|
#include "llvm/ProfileData/SampleProfReader.h"
Public Member Functions | |
SampleProfileReaderGCC (std::unique_ptr< MemoryBuffer > B, LLVMContext &C) | |
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... | |
![]() | |
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... | |
void | dumpJson (raw_ostream &OS=dbgs()) |
Print all the profiles on stream OS in the JSON format. 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 std::vector< StringRef > * | getNameTable () |
It includes all the names that have samples either in outline instance or inline instance. More... | |
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) |
Static Public Member Functions | |
static bool | hasFormat (const MemoryBuffer &Buffer) |
Return true if Buffer is in the format supported by this class. More... | |
![]() | |
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... | |
Protected Member Functions | |
std::error_code | readNameTable () |
std::error_code | readOneFunctionProfile (const InlineCallStack &InlineStack, bool Update, uint32_t Offset) |
std::error_code | readFunctionProfiles () |
std::error_code | skipNextWord () |
template<typename T > | |
ErrorOr< T > | readNumber () |
ErrorOr< StringRef > | readString () |
std::error_code | readSectionTag (uint32_t Expected) |
Read the section tag and check that it's the same as Expected . More... | |
![]() | |
void | computeSummary () |
Compute summary for this profile. More... | |
Protected Attributes | |
GCOVBuffer | GcovBuffer |
GCOV buffer containing the profile. More... | |
std::vector< std::string > | Names |
Function names in this profile. 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... | |
Static Protected Attributes | |
static const uint32_t | GCOVTagAFDOFileNames = 0xaa000000 |
GCOV tags used to separate sections in the profile file. More... | |
static const uint32_t | GCOVTagAFDOFunction = 0xac000000 |
Additional Inherited Members | |
![]() | |
static std::unique_ptr< ProfileSummary > | takeSummary (SampleProfileReader &Reader) |
Take ownership of the summary of this reader. More... | |
Definition at line 860 of file SampleProfReader.h.
|
inline |
Definition at line 862 of file SampleProfReader.h.
|
static |
Return true if Buffer
is in the format supported by this class.
Definition at line 1792 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReader::Buffer, and llvm::msf::Magic.
Referenced by llvm::sampleprof::SampleProfileReader::create().
|
protected |
Definition at line 1636 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReader::computeSummary(), I, llvm::success, and llvm::truncated.
|
overridevirtual |
Read and validate the file header.
Implements llvm::sampleprof::SampleProfileReader.
Definition at line 1583 of file SampleProfReader.cpp.
References llvm::success, llvm::unrecognized_format, llvm::unsupported_version, and llvm::GCOV::V407.
|
overridevirtual |
Read sample profiles from the associated file.
Read a GCC AutoFDO profile.
This format is generated by the Linux Perf conversion tool at https://github.com/google/autofdo.
Implements llvm::sampleprof::SampleProfileReader.
Definition at line 1779 of file SampleProfReader.cpp.
References assert(), ProfileIsFSDisciminator, llvm::sampleprof::SampleProfileReaderBinary::readNameTable(), and llvm::success.
|
protected |
Definition at line 1618 of file SampleProfReader.cpp.
References I, llvm::success, and llvm::truncated.
Definition at line 1560 of file SampleProfReader.cpp.
References llvm::malformed, llvm::max(), and llvm::sampleprof::SampleProfileReader::reportError().
|
protected |
Definition at line 1653 of file SampleProfReader.cpp.
References llvm::sampleprof::FunctionSamples::addBodySamples(), llvm::sampleprof::FunctionSamples::addCalledTargetSamples(), llvm::sampleprof::FunctionSamples::addHeadSamples(), llvm::append_range(), llvm::sampleprof::FunctionSamples::functionSamplesAt(), llvm::sampleprof::FunctionSamples::getTotalSamples(), llvm::sampleprof::HIST_TYPE_INDIR_CALL_TOPN, I, llvm::malformed, llvm::sampleprof::SampleProfileReader::Profiles, llvm::sampleprof::FunctionSamples::setName(), llvm::success, and llvm::truncated.
|
protected |
Read the section tag and check that it's the same as Expected
.
Definition at line 1604 of file SampleProfReader.cpp.
References llvm::malformed, llvm::success, and llvm::truncated.
Definition at line 1576 of file SampleProfReader.cpp.
References llvm::truncated.
|
protected |
Definition at line 1553 of file SampleProfReader.cpp.
References llvm::success, and llvm::truncated.
|
protected |
GCOV buffer containing the profile.
Definition at line 888 of file SampleProfReader.h.
|
staticprotected |
GCOV tags used to separate sections in the profile file.
Definition at line 894 of file SampleProfReader.h.
|
staticprotected |
Definition at line 895 of file SampleProfReader.h.
|
protected |
Function names in this profile.
Definition at line 891 of file SampleProfReader.h.