LLVM 22.0.0git
llvm::sampleprof::SampleProfileReaderGCC Class Reference

#include "llvm/ProfileData/SampleProfReader.h"

Inheritance diagram for llvm::sampleprof::SampleProfileReaderGCC:
[legend]

Public Member Functions

 SampleProfileReaderGCC (std::unique_ptr< MemoryBuffer > B, LLVMContext &C)
std::error_code readHeader () override
 Read and validate the file header.
std::error_code readImpl () override
 Read sample profiles from the associated file.
Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
 SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
virtual ~SampleProfileReader ()=default
void setDiscriminatorMaskedBitFrom (FSDiscriminatorPass P)
 Set the bits for FS discriminators.
uint32_t getDiscriminatorMask () const
 Get the bitmask the discriminators: For FS profiles, return the bit mask for this pass.
std::error_code read ()
 The interface to read sample profiles from the associated file.
std::error_code read (const DenseSet< StringRef > &FuncsToUse)
 Read sample profiles for the given functions.
LLVM_ABI void dumpFunctionProfile (const FunctionSamples &FS, raw_ostream &OS=dbgs())
 Print the profile for FunctionSamples on stream OS.
virtual bool collectFuncsFromModule ()
 Collect functions with definitions in Module M.
LLVM_ABI void dump (raw_ostream &OS=dbgs())
 Print all the profiles on stream OS.
LLVM_ABI void dumpJson (raw_ostream &OS=dbgs())
 Print all the profiles on stream OS in the JSON format.
FunctionSamplesgetSamplesFor (const Function &F)
 Return the samples collected for function F.
FunctionSamplesgetSamplesFor (StringRef Fname)
 Return the samples collected for function F.
SampleProfileMapgetProfiles ()
 Return all the profiles.
void reportError (int64_t LineNumber, const Twine &Msg) const
 Report a parse error message.
ProfileSummarygetSummary () const
 Return the profile summary.
MemoryBuffergetBuffer () const
SampleProfileFormat getFormat () const
 Return the profile format.
bool profileIsProbeBased () const
 Whether input profile is based on pseudo probes.
bool profileIsCS () const
 Whether input profile is fully context-sensitive.
bool profileIsPreInlined () const
 Whether input profile contains ShouldBeInlined contexts.
bool profileIsFS () const
 Whether input profile is flow-sensitive.
virtual std::unique_ptr< ProfileSymbolListgetProfileSymbolList ()
virtual std::vector< FunctionId > * getNameTable ()
 It includes all the names that have samples either in outline instance or inline instance.
virtual bool dumpSectionInfo (raw_ostream &OS=dbgs())
bool useMD5 () const
 Return whether names in the profile are all MD5 numbers.
virtual void setProfileUseMD5 ()
 Force the profile to use MD5 in Sample contexts, even if function names are present.
void setSkipFlatProf (bool Skip)
 Don't read profile without context if the flag is set.
virtual bool hasUniqSuffix ()
 Return whether any name in the profile contains ".__uniq." suffix.
SampleProfileReaderItaniumRemappergetRemapper ()
void setModule (const Module *Mod)
void setFuncNameToProfNameMap (const HashKeyMap< std::unordered_map, FunctionId, FunctionId > &FPMap)

Static Public Member Functions

static bool hasFormat (const MemoryBuffer &Buffer)
 Return true if Buffer is in the format supported by this class.
Static Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
static LLVM_ABI ErrorOr< std::unique_ptr< SampleProfileReader > > create (StringRef Filename, LLVMContext &C, vfs::FileSystem &FS, FSDiscriminatorPass P=FSDiscriminatorPass::Base, StringRef RemapFilename="")
 Create a sample profile reader appropriate to the file format.
static LLVM_ABI ErrorOr< std::unique_ptr< SampleProfileReader > > create (std::unique_ptr< MemoryBuffer > &B, LLVMContext &C, vfs::FileSystem &FS, FSDiscriminatorPass P=FSDiscriminatorPass::Base, StringRef RemapFilename="")
 Create a sample profile reader from the supplied memory buffer.

Protected Member Functions

std::error_code readNameTable ()
std::error_code readOneFunctionProfile (const InlineCallStack &InlineStack, bool Update, uint32_t Offset)
std::error_code readFunctionProfiles ()
std::error_code skipNextWord ()
template<typename T>
ErrorOr< TreadNumber ()
ErrorOr< StringRefreadString ()
std::error_code readSectionTag (uint32_t Expected)
 Read the section tag and check that it's the same as Expected.
Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
LLVM_ABI void computeSummary ()
 Compute summary for this profile.
virtual std::error_code read (const DenseSet< StringRef > &FuncsToUse, SampleProfileMap &Profiles)
 Read sample profiles for the given functions and write them to the given profile map.

Protected Attributes

GCOVBuffer GcovBuffer
 GCOV buffer containing the profile.
std::vector< std::string > Names
 Function names in this profile.
Protected Attributes inherited from llvm::sampleprof::SampleProfileReader
SampleProfileMap Profiles
 Map every function to its associated profile.
LLVMContextCtx
 LLVM context used to emit diagnostics.
std::unique_ptr< MemoryBufferBuffer
 Memory buffer holding the profile file.
std::unique_ptr< ProfileSummarySummary
 Profile summary information.
std::unique_ptr< SampleProfileReaderItaniumRemapperRemapper
const HashKeyMap< std::unordered_map, FunctionId, FunctionId > * FuncNameToProfNameMap = nullptr
std::unordered_map< uint64_t, std::pair< const uint8_t *, const uint8_t * > > FuncMetadataIndex
std::pair< const uint8_t *, const uint8_t * > ProfileSecRange
bool ProfileHasAttribute = false
 Whether the profile has attribute metadata.
bool ProfileIsProbeBased = false
 Whether samples are collected based on pseudo probes.
bool ProfileIsCS = false
 Whether function profiles are context-sensitive flat profiles.
bool ProfileIsPreInlined = false
 Whether function profile contains ShouldBeInlined contexts.
uint32_t CSProfileCount = 0
 Number of context-sensitive profiles.
bool ProfileIsFS = false
 Whether the function profiles use FS discriminators.
bool ReadVTableProf = false
 If true, the profile has vtable profiles and reader should decode them to parse profiles correctly.
SampleProfileFormat Format = SPF_None
 The format of sample.
const ModuleM = nullptr
 The current module being compiled if SampleProfileReader is used by compiler.
uint32_t MaskedBitFrom = 31
 Zero out the discriminator bits higher than bit MaskedBitFrom (0 based).
bool ProfileIsMD5 = false
 Whether the profile uses MD5 for Sample Contexts and function names.
bool SkipFlatProf = false
 If SkipFlatProf is true, skip functions marked with !Flat in text mode or sections with SecFlagFlat flag in ExtBinary mode.

Static Protected Attributes

static const uint32_t GCOVTagAFDOFileNames = 0xaa000000
 GCOV tags used to separate sections in the profile file.
static const uint32_t GCOVTagAFDOFunction = 0xac000000

Additional Inherited Members

Static Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
static std::unique_ptr< ProfileSummarytakeSummary (SampleProfileReader &Reader)
 Take ownership of the summary of this reader.

Detailed Description

Definition at line 897 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileReaderGCC()

llvm::sampleprof::SampleProfileReaderGCC::SampleProfileReaderGCC ( std::unique_ptr< MemoryBuffer > B,
LLVMContext & C )
inline

Member Function Documentation

◆ hasFormat()

bool SampleProfileReaderGCC::hasFormat ( const MemoryBuffer & Buffer)
static

Return true if Buffer is in the format supported by this class.

Definition at line 1964 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer.

Referenced by llvm::sampleprof::SampleProfileReader::create().

◆ readFunctionProfiles()

std::error_code SampleProfileReaderGCC::readFunctionProfiles ( )
protected

◆ readHeader()

std::error_code SampleProfileReaderGCC::readHeader ( )
overridevirtual

◆ readImpl()

std::error_code SampleProfileReaderGCC::readImpl ( )
overridevirtual

Read sample profiles from the associated file.

Read a GCC AutoFDO profile.

This format is generated by the Linux Perf conversion tool at https://github.com/google/autofdo.

Implements llvm::sampleprof::SampleProfileReader.

Definition at line 1951 of file SampleProfReader.cpp.

References assert(), ProfileIsFSDisciminator, readFunctionProfiles(), readNameTable(), and llvm::success.

◆ readNameTable()

std::error_code SampleProfileReaderGCC::readNameTable ( )
protected

◆ readNumber()

template<typename T>
ErrorOr< T > SampleProfileReaderGCC::readNumber ( )
protected

◆ readOneFunctionProfile()

◆ readSectionTag()

std::error_code SampleProfileReaderGCC::readSectionTag ( uint32_t Expected)
protected

Read the section tag and check that it's the same as Expected.

Definition at line 1775 of file SampleProfReader.cpp.

References GcovBuffer, llvm::malformed, skipNextWord(), llvm::success, llvm::Tag, and llvm::truncated.

Referenced by readFunctionProfiles(), and readNameTable().

◆ readString()

ErrorOr< StringRef > SampleProfileReaderGCC::readString ( )
protected

Definition at line 1747 of file SampleProfReader.cpp.

References GcovBuffer, and llvm::truncated.

◆ skipNextWord()

std::error_code SampleProfileReaderGCC::skipNextWord ( )
protected

Definition at line 1724 of file SampleProfReader.cpp.

References GcovBuffer, llvm::success, and llvm::truncated.

Referenced by readHeader(), and readSectionTag().

Member Data Documentation

◆ GcovBuffer

GCOVBuffer llvm::sampleprof::SampleProfileReaderGCC::GcovBuffer
protected

◆ GCOVTagAFDOFileNames

const uint32_t llvm::sampleprof::SampleProfileReaderGCC::GCOVTagAFDOFileNames = 0xaa000000
staticprotected

GCOV tags used to separate sections in the profile file.

Definition at line 931 of file SampleProfReader.h.

Referenced by readNameTable().

◆ GCOVTagAFDOFunction

const uint32_t llvm::sampleprof::SampleProfileReaderGCC::GCOVTagAFDOFunction = 0xac000000
staticprotected

Definition at line 932 of file SampleProfReader.h.

Referenced by readFunctionProfiles().

◆ Names

std::vector<std::string> llvm::sampleprof::SampleProfileReaderGCC::Names
protected

Function names in this profile.

Definition at line 928 of file SampleProfReader.h.

Referenced by readNameTable(), and readOneFunctionProfile().


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