LLVM
10.0.0svn
|
SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase defines the basic structure of the extensible binary format. More...
#include "llvm/ProfileData/SampleProfReader.h"
Public Member Functions | |
SampleProfileReaderExtBinaryBase (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format) | |
std::error_code | readImpl () override |
Read sample profiles in extensible format from the associated file. More... | |
uint64_t | getSectionSize (SecType Type) |
Get the total size of all Type sections. More... | |
uint64_t | getFileSize () |
Get the total size of header and all sections. More... | |
virtual bool | dumpSectionInfo (raw_ostream &OS=dbgs()) override |
![]() | |
SampleProfileReaderBinary (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None) | |
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 |
std::error_code | read () |
The interface to read sample profiles from the associated file. More... | |
void | dumpFunctionProfile (StringRef FName, raw_ostream &OS=dbgs()) |
Print the profile for FName on stream OS . More... | |
virtual void | collectFuncsFrom (const Module &M) |
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... | |
virtual FunctionSamples * | getSamplesFor (StringRef Fname) |
Return the samples collected for function F . More... | |
StringMap< FunctionSamples > & | getProfiles () |
Return all the profiles. More... | |
void | reportError (int64_t LineNumber, 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... | |
virtual std::unique_ptr< ProfileSymbolList > | getProfileSymbolList () |
Protected Member Functions | |
std::error_code | readSecHdrTableEntry () |
std::error_code | readSecHdrTable () |
virtual std::error_code | readHeader () override |
Read and validate the file header. More... | |
virtual std::error_code | verifySPMagic (uint64_t Magic) override=0 |
virtual std::error_code | readOneSection (const uint8_t *Start, uint64_t Size, SecType Type)=0 |
![]() | |
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... | |
![]() | |
void | computeSummary () |
Compute summary for this profile. More... | |
Protected Attributes | |
std::vector< SecHdrTableEntry > | SecHdrTable |
std::unique_ptr< ProfileSymbolList > | ProfSymList |
![]() | |
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... | |
![]() | |
StringMap< FunctionSamples > | 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::unique_ptr< ProfileSummary > | Summary |
Profile summary information. More... | |
std::unique_ptr< SampleProfileReaderItaniumRemapper > | Remapper |
SampleProfileFormat | Format = SPF_None |
The format of sample. More... | |
Additional Inherited Members | |
![]() | |
static ErrorOr< std::unique_ptr< SampleProfileReader > > | create (const std::string Filename, LLVMContext &C, 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, 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... | |
SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase defines the basic structure of the extensible binary format.
The format is organized in sections except the magic and version number at the beginning. There is a section table before all the sections, and each entry in the table describes the entry type, start, size and attributes. The format in each section is defined by the section itself.
It is easy to add a new section while maintaining the backward compatibility of the profile. Nothing extra needs to be done. If we want to extend an existing section, like add cache misses information in addition to the sample count in the profile body, we can add a new section with the extension and retire the existing section, and we could choose to keep the parser of the old section if we want the reader to be able to read both new and old format profile.
SampleProfileReaderExtBinary/SampleProfileWriterExtBinary define the commonly used sections of a profile in extensible binary format. It is possible to define other types of profile inherited from SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase.
Definition at line 567 of file SampleProfReader.h.
|
inline |
Definition at line 587 of file SampleProfReader.h.
References llvm::dbgs().
|
overridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileReader.
Definition at line 796 of file SampleProfReader.cpp.
References assert(), llvm::sampleprof::getSecName(), and llvm::BTF::HeaderSize.
uint64_t SampleProfileReaderExtBinaryBase::getFileSize | ( | ) |
Get the total size of header and all sections.
Definition at line 783 of file SampleProfReader.cpp.
References llvm::max().
uint64_t SampleProfileReaderExtBinaryBase::getSectionSize | ( | SecType | Type | ) |
Get the total size of all Type
sections.
Definition at line 775 of file SampleProfReader.cpp.
|
overrideprotectedvirtual |
Read and validate the file header.
Reimplemented from llvm::sampleprof::SampleProfileReaderBinary.
Definition at line 760 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReader::Buffer, and llvm::Data.
|
overridevirtual |
Read sample profiles in extensible format from the associated file.
Reimplemented from llvm::sampleprof::SampleProfileReaderBinary.
Definition at line 604 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReader::Buffer, llvm::Data, llvm::sampleprof::hasSecFlag(), llvm::malformed, and llvm::sampleprof::SecFlagCompress.
|
protectedpure virtual |
|
protected |
Definition at line 748 of file SampleProfReader.cpp.
References llvm::success.
|
protected |
Definition at line 722 of file SampleProfReader.cpp.
|
overrideprotectedpure virtual |
Implements llvm::sampleprof::SampleProfileReaderBinary.
|
protected |
Definition at line 578 of file SampleProfReader.h.
|
protected |
Definition at line 577 of file SampleProfReader.h.