llvm::sampleprof::SampleProfileReaderExtBinaryBase

Base reader for sample profiles in the extensible binary format.

Synopsis

Declared in <llvm/ProfileData/SampleProfReader.h>

class SampleProfileReaderExtBinaryBase
    : public SampleProfileReaderBinary

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.

Base Classes

NameDescription
SampleProfileReaderBinarySample profile reader for binary profile formats.

Member Functions

NameDescription
SampleProfileReaderExtBinaryBase [constructor]Construct an extensible-binary base reader for buffer B.
collectFuncsFromModule [virtual]Collect functions with definitions in Module M. Return true if the reader has been given a module.
contains contains overloads
dump Print all the profiles on stream OS.
dumpFunctionProfile Print the profile for FunctionSamples on stream OS.
dumpJson Print all the profiles on stream OS in the JSON format.
dumpSectionInfo [virtual]Dump section header information to OS.
getBuffer Return the memory buffer holding the profile.
getDiscriminatorMask Get the bitmask the discriminators: For FS profiles, return the bit mask for this pass. For non FS profiles, return (unsigned) -1.
getFileSize Get the total size of header and all sections.
getFormat Return the profile format.
getFormatVersion Return the format version of the profile. For tests only.
getNameTable [virtual]It includes all the names that have samples either in outline instance or inline instance.
getProfileSymbolList [virtual]Take ownership of the loaded profile symbol list, if any.
getProfiles Return all the profiles.
getRemapper Return the Itanium remapper associated with this reader, if any.
getSamplesFor Return the samples collected for function F.
getSectionSize Get the total size of all Type sections.
getSummary Return the profile summary.
hasUniqSuffix [virtual]Return whether any name in the profile contains ".__uniq." suffix.
profileIsCS Whether input profile is fully context-sensitive.
profileIsFS Whether input profile is flow-sensitive.
profileIsPreInlined Whether input profile contains ShouldBeInlined contexts.
profileIsProbeBased Whether input profile is based on pseudo probes.
read read overloads
readHeader [virtual]Read and validate the file header.
readImpl [virtual]Read sample profiles in extensible format from the associated file.
reportError Report a parse error message.
setDiscriminatorMaskedBitFrom Set the masked bit range used for FS discriminators.
setFuncNameToProfNameMap Set the function-name to profile-name map used during lookup.
setModule Set the module currently being compiled.
setProfileUseMD5 [virtual]Force the profile to use MD5 in Sample contexts, even if function names are present.
setSkipFlatProf Don't read profile without context if the flag is set.
useMD5 Return whether names in the profile are all MD5 numbers.

Static Member Functions

NameDescription
create create overloads

Protected Member Functions

NameDescription
computeSummary Compute summary for this profile.
read [virtual]Read sample profiles for selected functions into Profiles.
readCSNameTableSec Read the context-sensitive name table section.
readCallsiteVTableProf Read all virtual functions' vtable access counts for FProfile.
readContextFromTable Read a context indirectly via the CSNameTable. Optionally return the index.
readCustomSection [virtual]Dispatch reading of a custom section described by Entry.
readEytzingerFuncOffsetTable Read an Eytzinger-layout function offset table.
readFuncMetadata readFuncMetadata overloads
readFuncOffsetTable Read the function offset table in Eytzinger or legacy layout.
readFuncProfile readFuncProfile overloads
readFuncProfiles readFuncProfiles overloads
readHeader [virtual]Read and validate the extensible-binary file header.
readLegacyFuncOffsetTable Read a legacy (non-Eytzinger) function offset table.
readMD5ProfileSymbolList Read an MD5-based profile symbol list.
readMagicIdent Read the contents of Magic number and Version number.
readNameTable Read the whole name table.
readNameTableSec Read the name table section.
readNameTableSecEytzinger Read an Eytzinger-layout name table section.
readNameTableSecLegacy Read a legacy (non-Eytzinger) name table section.
readNumber Read a numeric value of type T from the profile.
readOneSection [virtual]Read one section described by Entry starting at Start.
readProfile Read the contents of the given profile instance.
readProfileSymbolList Read the profile symbol list section.
readSampleContextFromTable Read a context indirectly via the CSNameTable if the profile has context, otherwise same as readStringFromTable, also return its hash value.
readSecHdrTable Read the full section header table.
readSecHdrTableEntry Read the section header table entry at index Idx.
readString Read a string from the profile.
readStringBasedProfileSymbolList Read a string-based profile symbol list.
readStringFromTable Read a string indirectly via the name table. Optionally return the index.
readStringIndex Read the string index and check whether it overflows the table.
readSummary Read profile summary.
readUnencodedNumber Read a numeric value of type T from the profile. The value is saved without encoded.
readVTableTypeCountMap Decode a vtable type-count map from the input buffer into M.
useFuncOffsetList Determine which container readFuncOffsetTable() should populate, the list FuncOffsetList or the map FuncOffsetTable.
verifySPMagic [virtual]Verify that Magic is a valid extensible-binary sample profile magic.

Protected Static Member Functions

NameDescription
takeSummary Take ownership of the summary of this reader.

Protected Data Members

NameDescription
Buffer Memory buffer holding the profile file.
CSNameTable CSNameTable is used to save full context vectors. It is the backing buffer for SampleContextFrames.
CSProfileCount Number of context-sensitive profiles.
Ctx LLVM context used to emit diagnostics.
Data Points to the current location in the buffer.
End Points to the end of the buffer.
Format The format of sample.
FormatVersion Format version of the profile.
FuncMetadataIndex Map from context hash to metadata section range for on-demand reads.
FuncNameToProfNameMap Map from IR function names to matched profile names.
FuncOffsetList The list version of FuncOffsetTable. This is used if every entry is being accessed.
FuncOffsetTable Map from a function context MD5 to its FunctionSamples file offset.
FuncsToUse The set containing the functions to use when compiling a module.
M Module currently being compiled, if any.
MD5SampleContextStart Starting address of the MD5 sample-context table.
MD5SampleContextTable Table to cache MD5 values of sample contexts corresponding to readSampleContextFromTable(), used to index into Profiles or FuncOffsetTable.
MaskedBitFrom Zero out the discriminator bits higher than bit MaskedBitFrom (0 based). The default is to keep all the bits.
NameTable Function name table.
ProfSymList Profile symbol list loaded from the profile, if present.
ProfileHasAttribute Whether the profile has attribute metadata.
ProfileIsCS Whether function profiles are context-sensitive flat profiles.
ProfileIsFS Whether the function profiles use FS discriminators.
ProfileIsMD5 Whether the profile uses MD5 for Sample Contexts and function names. This can be one-way overriden by the user to force use MD5.
ProfileIsPreInlined Whether function profile contains ShouldBeInlined contexts.
ProfileIsProbeBased Whether samples are collected based on pseudo probes.
ProfileSecRange Byte range of the main profile section in the buffer.
Profiles Map every function to its associated profile.
ReadVTableProf If true, the profile has vtable profiles and reader should decode them to parse profiles correctly.
Remapper Optional remapper applied after profiles are read.
SecHdrTable Section header table describing each profile section.
SkipFlatProf If SkipFlatProf is true, skip functions marked with !Flat in text mode or sections with SecFlagFlat flag in ExtBinary mode.
Summary Profile summary information.

Derived Classes

NameDescription
SampleProfileReaderExtBinary Sample profile reader for the common extensible binary format sections.