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:469
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 Summary
- protected Remapper
- protected Format = SPF_None
Method Overview
- public SampleProfileReaderBinary(std::unique_ptr<MemoryBuffer> B, llvm::LLVMContext & C, llvm::sampleprof::SampleProfileFormat Format = SPF_None)
- protected bool at_eof() const
- public virtual std::vector<StringRef> * getNameTable()
- protected std::error_code readFuncProfile(const uint8_t * Start)
- public virtual std::error_code readHeader()
- public std::error_code readImpl()
- protected std::error_code readMagicIdent()
- protected virtual std::error_code readNameTable()
- protected template <typename T>ErrorOr<T> readNumber()
- protected std::error_code readProfile(llvm::sampleprof::FunctionSamples & FProfile)
- protected ErrorOr<llvm::StringRef> readString()
- protected virtual ErrorOr<llvm::StringRef> readStringFromTable()
- protected template <typename T>inline ErrorOr<uint32_t> readStringIndex(T & Table)
- protected std::error_code readSummary()
- protected template <typename T>ErrorOr<T> readUnencodedNumber()
Inherited from SampleProfileReader:
- public collectFuncsFrom
- protected computeSummary
- public create
- public create
- public dump
- public dumpFunctionProfile
- public dumpSectionInfo
- public getBuffer
- public getFormat
- public getNameTable
- public getOrCreateSamplesFor
- public getProfileSymbolList
- public getProfiles
- public getSamplesFor
- public getSamplesFor
- public getSummary
- public read
- public readHeader
- public readImpl
- public reportError
- protected takeSummary
Methods
¶SampleProfileReaderBinary(
std::unique_ptr<MemoryBuffer> B,
llvm::LLVMContext& C,
llvm::sampleprof::SampleProfileFormat Format =
SPF_None)
SampleProfileReaderBinary(
std::unique_ptr<MemoryBuffer> B,
llvm::LLVMContext& C,
llvm::sampleprof::SampleProfileFormat Format =
SPF_None)
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:471
Parameters
- std::unique_ptr<MemoryBuffer> B
- llvm::LLVMContext& C
- llvm::sampleprof::SampleProfileFormat Format = SPF_None
¶bool at_eof() const
bool at_eof() const
Description
Return true if we've reached the end of file.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:510
¶virtual std::vector<StringRef>* getNameTable()
virtual 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:483
¶std::error_code readFuncProfile(
const uint8_t* Start)
std::error_code readFuncProfile(
const uint8_t* Start)
Description
Read the next function profile instance.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:513
Parameters
- const uint8_t* Start
¶virtual std::error_code readHeader()
virtual std::error_code readHeader()
Description
Read and validate the file header.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:476
¶std::error_code readImpl()
std::error_code readImpl()
Description
Read sample profiles from the associated file.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:479
¶std::error_code readMagicIdent()
std::error_code readMagicIdent()
Description
Read the contents of Magic number and Version number.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:519
¶virtual std::error_code readNameTable()
virtual std::error_code readNameTable()
Description
Read the whole name table.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:525
¶template <typename T>
ErrorOr<T> readNumber()
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:492
Templates
- T
Returns
the read value.
¶std::error_code readProfile(
llvm::sampleprof::FunctionSamples& FProfile)
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:516
Parameters
- llvm::sampleprof::FunctionSamples& FProfile
¶ErrorOr<llvm::StringRef> readString()
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:504
Returns
the read value.
¶virtual ErrorOr<llvm::StringRef>
readStringFromTable()
virtual ErrorOr<llvm::StringRef>
readStringFromTable()
Description
Read a string indirectly via the name table.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:537
¶template <typename T>
inline ErrorOr<uint32_t> readStringIndex(T& Table)
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:507
Templates
- T
Parameters
- T& Table
¶std::error_code readSummary()
std::error_code readSummary()
Description
Read profile summary.
Declared at: llvm/include/llvm/ProfileData/SampleProfReader.h:522
¶template <typename T>
ErrorOr<T> readUnencodedNumber()
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:496
Templates
- T