class SampleProfileReaderExtBinaryBase

Declaration

class SampleProfileReaderExtBinaryBase
    : public SampleProfileReaderBinary { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:689

Inherits from: SampleProfileReaderBinary

Member Variables

private llvm::BumpPtrAllocator Allocator
protected std::vector<SecHdrTableEntry> SecHdrTable
protected std::unique_ptr<ProfileSymbolList> ProfSymList
protected DenseMap<llvm::sampleprof::SampleContext, uint64_t> FuncOffsetTable
The table mapping from function context to the offset of its FunctionSample towards file start.
protected std::unique_ptr<std::vector< std::pair<SampleContext, uint64_t>>> OrderedFuncOffsets
Function offset mapping ordered by contexts.
protected DenseSet<llvm::StringRef> FuncsToUse
The set containing the functions to use when compiling a module.
protected bool FixedLengthMD5 = false
Use fixed length MD5 instead of ULEB128 encoding so NameTable doesn't need to be read in up front and can be directly accessed using index.
protected const uint8_t* MD5NameMemStart = nullptr
The starting address of NameTable containing fixed length MD5.
protected std::unique_ptr<std::vector<std::string>> MD5StringBuf
If MD5 is used in NameTable section, the section saves uint64_t data. The uint64_t data has to be converted to a string and then the string will be used to initialize StringRef in NameTable. Note NameTable contains StringRef so it needs another buffer to own the string data. MD5StringBuf serves as the string buffer that is referenced by NameTable (vector of StringRef). We make sure the lifetime of MD5StringBuf is not shorter than that of NameTable.
protected std::unique_ptr< const std::vector<SampleContextFrameVector>> CSNameTable
CSNameTable is used to save full context vectors. This serves as an underlying immutable buffer for all clients.
protected bool SkipFlatProf = false
If SkipFlatProf is true, skip the sections with SecFlagFlat flag.
protected bool FuncOffsetsOrdered = false

Inherited from SampleProfileReaderBinary:

protected Data = nullptr
protected End = nullptr
protected NameTable

Inherited from SampleProfileReader:

protected Profiles
protected Ctx
protected Buffer
protected MD5NameBuffer
protected Summary
protected Remapper
protected ProfileIsProbeBased = false
protected ProfileIsCS = false
protected ProfileIsPreInlined = false
protected CSProfileCount = 0
protected ProfileIsFS = false
protected Format = SPF_None
protected M = nullptr
protected MaskedBitFrom = 31

Method Overview

Inherited from SampleProfileReaderBinary:

Inherited from SampleProfileReader:

Methods

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

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:762

Parameters

std::unique_ptr<MemoryBuffer> B
llvm::LLVMContext& C
llvm::sampleprof::SampleProfileFormat Format

bool collectFuncsFromModule()

Description

Collect functions with definitions in Module M. Return true if the reader has been given a module.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:777

std::error_code decompressSection(
    const uint8_t* SecStart,
    const uint64_t SecSize,
    const uint8_t*& DecompressBuf,
    uint64_t& DecompressBufSize)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:691

Parameters

const uint8_t* SecStart
const uint64_t SecSize
const uint8_t*& DecompressBuf
uint64_t& DecompressBufSize

bool dumpSectionInfo(
    llvm::raw_ostream& OS = dbgs())

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:773

Parameters

llvm::raw_ostream& OS = dbgs()

uint64_t getFileSize()

Description

Get the total size of header and all sections.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:772

std::unique_ptr<ProfileSymbolList>
getProfileSymbolList()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:782

uint64_t getSectionSize(
    llvm::sampleprof::SecType Type)

Description

Get the total size of all \p Type sections.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:770

Parameters

llvm::sampleprof::SecType Type

std::error_code readCSNameTableSec()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:710

ErrorOr<llvm::sampleprof::SampleContextFrames>
readContextFromTable()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:721

virtual std::error_code readCustomSection(
    const llvm::sampleprof::SecHdrTableEntry&
        Entry)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:718

Parameters

const llvm::sampleprof::SecHdrTableEntry& Entry

std::error_code readFuncMetadata(
    bool ProfileHasAttribute,
    llvm::sampleprof::FunctionSamples* FProfile)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:704

Parameters

bool ProfileHasAttribute
llvm::sampleprof::FunctionSamples* FProfile

std::error_code readFuncMetadata(
    bool ProfileHasAttribute)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:703

Parameters

bool ProfileHasAttribute

std::error_code readFuncOffsetTable()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:706

std::error_code readFuncProfiles()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:707

std::error_code readHeader()

Description

Read and validate the file header.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:713

std::error_code readImpl()

Description

Read sample profiles in extensible format from the associated file.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:767

std::error_code readMD5NameTable()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:708

std::error_code readNameTableSec(bool IsMD5)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:709

Parameters

bool IsMD5

virtual std::error_code readOneSection(
    const uint8_t* Start,
    uint64_t Size,
    const llvm::sampleprof::SecHdrTableEntry&
        Entry)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:715

Parameters

const uint8_t* Start
uint64_t Size
const llvm::sampleprof::SecHdrTableEntry& Entry

std::error_code readProfileSymbolList()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:711

ErrorOr<llvm::sampleprof::SampleContext>
readSampleContextFromTable()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:720

std::error_code readSecHdrTable()

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:701

std::error_code readSecHdrTableEntry(uint32_t Idx)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:700

Parameters

uint32_t Idx

ErrorOr<llvm::StringRef> readStringFromTable()

Description

Read a string indirectly via the name table.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:719

void setSkipFlatProf(bool Skip)

Description

Don't read profile without context if the flag is set. This is only meaningful for ExtBinary format.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:786

Parameters

bool Skip

bool useMD5()

Description

Return whether names in the profile are all MD5 numbers.

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:780

std::error_code verifySPMagic(uint64_t Magic)

Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:714

Parameters

uint64_t Magic