class SampleProfileReaderBinary

Declaration

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

Description

Sample-based profile reader. Each profile contains sample counts for all the functions executed. Inside each function, statements are annotated with the collected samples on all the instructions associated with that statement. For this to produce meaningful data, the program needs to be compiled with some debug information (at minimum, line numbers: -gline-tables-only). Otherwise, it will be impossible to match IR instructions to the line numbers collected by the profiler. From the profile file, we are interested in collecting the following information: * A list of functions included in the profile (mangled names). * For each function F: 1. The total number of samples collected in F. 2. The samples collected at each line in F. To provide some protection against source code shuffling, line numbers should be relative to the start of the function. The reader supports two file formats: text and binary. The text format is useful for debugging and testing, while the binary format is more compact and I/O efficient. They can both be used interchangeably.

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

Inherits from: SampleProfileReader

Member Variables

protected const uint8_t* Data = nullptr
Points to the current location in the buffer.
protected const uint8_t* End = nullptr
Points to the end of the buffer.
protected std::vector<StringRef> NameTable
Function name table.

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 SampleProfileReader:

Methods

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

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

Parameters

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

bool at_eof() const

Description

Return true if we've reached the end of file.

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

std::vector<StringRef>* getNameTable()

Description

It includes all the names that have samples either in outline instance or inline instance.

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

std::error_code readFuncProfile(
    const uint8_t* Start)

Description

Read the next function profile instance.

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

Parameters

const uint8_t* Start

std::error_code readHeader()

Description

Read and validate the file header.

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

std::error_code readImpl()

Description

Read sample profiles from the associated file.

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

std::error_code readMagicIdent()

Description

Read the contents of Magic number and Version number.

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

virtual std::error_code readNameTable()

Description

Read the whole name table.

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

template <typename T>
ErrorOr<T> readNumber()

Description

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.

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

Templates

T

Returns

the read value.

std::error_code readProfile(
    llvm::sampleprof::FunctionSamples& FProfile)

Description

Read the contents of the given profile instance.

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

Parameters

llvm::sampleprof::FunctionSamples& FProfile

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

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

ErrorOr<llvm::StringRef> readString()

Description

Read a string from the profile. If an error occurs during decoding, a diagnostic message is emitted and EC is set.

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

Returns

the read value.

virtual ErrorOr<llvm::StringRef>
readStringFromTable()

Description

Read a string indirectly via the name table.

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

template <typename T>
inline ErrorOr<uint32_t> readStringIndex(T& Table)

Description

Read the string index and check whether it overflows the table.

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

Templates

T

Parameters

T& Table

std::error_code readSummary()

Description

Read profile summary.

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

std::error_code readSummaryEntry(
    std::vector<ProfileSummaryEntry>& Entries)

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

Parameters

std::vector<ProfileSummaryEntry>& Entries

template <typename T>
ErrorOr<T> readUnencodedNumber()

Description

Read a numeric value of type T from the profile. The value is saved without encoded.

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

Templates

T

virtual std::error_code verifySPMagic(
    uint64_t Magic)

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

Parameters

uint64_t Magic