LLVM  10.0.0svn
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::sampleprof::SampleProfileReaderExtBinaryBase Class Referenceabstract

SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase defines the basic structure of the extensible binary format. More...

#include "llvm/ProfileData/SampleProfReader.h"

Inheritance diagram for llvm::sampleprof::SampleProfileReaderExtBinaryBase:
Inheritance graph
[legend]
Collaboration diagram for llvm::sampleprof::SampleProfileReaderExtBinaryBase:
Collaboration graph
[legend]

Public Member Functions

 SampleProfileReaderExtBinaryBase (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format)
 
std::error_code read () 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
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileReaderBinary
 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...
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
 SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
 
virtual ~SampleProfileReader ()=default
 
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...
 
FunctionSamplesgetSamplesFor (const Function &F)
 Return the samples collected for function F. More...
 
virtual FunctionSamplesgetSamplesFor (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...
 
ProfileSummarygetSummary ()
 Return the profile summary. More...
 
SampleProfileFormat getFormat ()
 Return the profile format. More...
 
virtual std::unique_ptr< ProfileSymbolListgetProfileSymbolList ()
 

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
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileReaderBinary
template<typename T >
ErrorOr< TreadNumber ()
 Read a numeric value of type T from the profile. More...
 
template<typename T >
ErrorOr< TreadUnencodedNumber ()
 Read a numeric value of type T from the profile. More...
 
ErrorOr< StringRefreadString ()
 Read a string from the profile. More...
 
template<typename T >
ErrorOr< uint32_treadStringIndex (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< StringRefreadStringFromTable ()
 Read a string indirectly via the name table. More...
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
void computeSummary ()
 Compute summary for this profile. More...
 

Protected Attributes

std::vector< SecHdrTableEntrySecHdrTable
 
std::unique_ptr< ProfileSymbolListProfSymList
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileReaderBinary
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< StringRefNameTable
 Function name table. More...
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileReader
StringMap< FunctionSamplesProfiles
 Map every function to its associated profile. More...
 
LLVMContextCtx
 LLVM context used to emit diagnostics. More...
 
std::unique_ptr< MemoryBufferBuffer
 Memory buffer holding the profile file. More...
 
std::unique_ptr< ProfileSummarySummary
 Profile summary information. More...
 
SampleProfileFormat Format = SPF_None
 The format of sample. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
static ErrorOr< std::unique_ptr< SampleProfileReader > > create (const Twine &Filename, LLVMContext &C)
 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)
 Create a sample profile reader from the supplied memory buffer. More...
 
- Static Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
static std::unique_ptr< ProfileSummarytakeSummary (SampleProfileReader &Reader)
 Take ownership of the summary of this reader. More...
 

Detailed Description

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 490 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileReaderExtBinaryBase()

llvm::sampleprof::SampleProfileReaderExtBinaryBase::SampleProfileReaderExtBinaryBase ( std::unique_ptr< MemoryBuffer B,
LLVMContext C,
SampleProfileFormat  Format 
)
inline

Member Function Documentation

◆ dumpSectionInfo()

bool SampleProfileReaderExtBinaryBase::dumpSectionInfo ( raw_ostream OS = dbgs())
overridevirtual

◆ getFileSize()

uint64_t SampleProfileReaderExtBinaryBase::getFileSize ( )

Get the total size of header and all sections.

Definition at line 775 of file SampleProfReader.cpp.

References llvm::max().

◆ getSectionSize()

uint64_t SampleProfileReaderExtBinaryBase::getSectionSize ( SecType  Type)

Get the total size of all Type sections.

Definition at line 767 of file SampleProfReader.cpp.

◆ read()

std::error_code SampleProfileReaderExtBinaryBase::read ( )
overridevirtual

Read sample profiles in extensible format from the associated file.

Reimplemented from llvm::sampleprof::SampleProfileReaderBinary.

Definition at line 596 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer, llvm::Data, llvm::sampleprof::hasSecFlag(), llvm::malformed, and llvm::sampleprof::SecFlagCompress.

◆ readHeader()

std::error_code SampleProfileReaderExtBinaryBase::readHeader ( )
overrideprotectedvirtual

Read and validate the file header.

Reimplemented from llvm::sampleprof::SampleProfileReaderBinary.

Definition at line 752 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer, and llvm::Data.

◆ readOneSection()

virtual std::error_code llvm::sampleprof::SampleProfileReaderExtBinaryBase::readOneSection ( const uint8_t *  Start,
uint64_t  Size,
SecType  Type 
)
protectedpure virtual

◆ readSecHdrTable()

std::error_code SampleProfileReaderExtBinaryBase::readSecHdrTable ( )
protected

Definition at line 740 of file SampleProfReader.cpp.

References llvm::success.

◆ readSecHdrTableEntry()

std::error_code SampleProfileReaderExtBinaryBase::readSecHdrTableEntry ( )
protected

Definition at line 714 of file SampleProfReader.cpp.

◆ verifySPMagic()

virtual std::error_code llvm::sampleprof::SampleProfileReaderExtBinaryBase::verifySPMagic ( uint64_t  Magic)
overrideprotectedpure virtual

Member Data Documentation

◆ ProfSymList

std::unique_ptr<ProfileSymbolList> llvm::sampleprof::SampleProfileReaderExtBinaryBase::ProfSymList
protected

Definition at line 501 of file SampleProfReader.h.

◆ SecHdrTable

std::vector<SecHdrTableEntry> llvm::sampleprof::SampleProfileReaderExtBinaryBase::SecHdrTable
protected

Definition at line 500 of file SampleProfReader.h.


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