LLVM  14.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::sampleprof::SampleProfileReaderBinary Class Referenceabstract

#include "llvm/ProfileData/SampleProfReader.h"

Inheritance diagram for llvm::sampleprof::SampleProfileReaderBinary:
Inheritance graph
[legend]
Collaboration diagram for llvm::sampleprof::SampleProfileReaderBinary:
Collaboration graph
[legend]

Public Member Functions

 SampleProfileReaderBinary (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
 
virtual std::error_code readHeader () override
 Read and validate the file header. More...
 
std::error_code readImpl () override
 Read sample profiles from the associated file. More...
 
virtual std::vector< StringRef > * getNameTable () override
 It includes all the names that have samples either in outline instance or inline instance. More...
 
- 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. More...
 
uint32_t getDiscriminatorMask () const
 Get the bitmask the discriminators: For FS profiles, return the bit mask for this pass. More...
 
std::error_code read ()
 The interface to read sample profiles from the associated file. More...
 
void dumpFunctionProfile (SampleContext FContext, raw_ostream &OS=dbgs())
 Print the profile for FContext on stream OS. More...
 
virtual bool collectFuncsFromModule ()
 Collect functions with definitions in Module M. More...
 
void dump (raw_ostream &OS=dbgs())
 Print all the profiles on stream OS. More...
 
FunctionSamplesgetSamplesFor (const Function &F)
 Return the samples collected for function F. More...
 
FunctionSamplesgetOrCreateSamplesFor (const Function &F)
 Return the samples collected for function F, create empty FunctionSamples if it doesn't exist. More...
 
virtual FunctionSamplesgetSamplesFor (StringRef Fname)
 Return the samples collected for function F. More...
 
SampleProfileMapgetProfiles ()
 Return all the profiles. More...
 
void reportError (int64_t LineNumber, const Twine &Msg) const
 Report a parse error message. More...
 
ProfileSummarygetSummary () const
 Return the profile summary. More...
 
MemoryBuffergetBuffer () const
 
SampleProfileFormat getFormat () const
 Return the profile format. More...
 
bool profileIsProbeBased () const
 Whether input profile is based on pseudo probes. More...
 
bool profileIsCS () const
 Whether input profile is fully context-sensitive. More...
 
virtual std::unique_ptr< ProfileSymbolListgetProfileSymbolList ()
 
virtual bool dumpSectionInfo (raw_ostream &OS=dbgs())
 
virtual bool useMD5 ()
 Return whether names in the profile are all MD5 numbers. More...
 
virtual void setSkipFlatProf (bool Skip)
 Don't read profile without context if the flag is set. More...
 
virtual bool hasUniqSuffix ()
 Return whether any name in the profile contains ".__uniq." suffix. More...
 
SampleProfileReaderItaniumRemappergetRemapper ()
 
void setModule (const Module *Mod)
 

Protected Member Functions

template<typename T >
ErrorOr< TreadNumber ()
 Read a numeric value of type T from the profile. More...
 
template<typename T >
ErrorOr< TreadUnencodedNumber ()
 Read a numeric value of type T from the profile. More...
 
ErrorOr< StringRefreadString ()
 Read a string from the profile. More...
 
template<typename T >
ErrorOr< uint32_treadStringIndex (T &Table)
 Read the string index and check whether it overflows the table. More...
 
bool at_eof () const
 Return true if we've reached the end of file. More...
 
std::error_code readFuncProfile (const uint8_t *Start)
 Read the next function profile instance. More...
 
std::error_code readProfile (FunctionSamples &FProfile)
 Read the contents of the given profile instance. More...
 
std::error_code readMagicIdent ()
 Read the contents of Magic number and Version number. More...
 
std::error_code readSummary ()
 Read profile summary. More...
 
virtual std::error_code readNameTable ()
 Read the whole name table. More...
 
virtual ErrorOr< StringRefreadStringFromTable ()
 Read a string indirectly via the name table. More...
 
virtual ErrorOr< SampleContextreadSampleContextFromTable ()
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
void computeSummary ()
 Compute summary for this profile. More...
 

Protected Attributes

const uint8_t * Data = nullptr
 Points to the current location in the buffer. More...
 
const uint8_t * End = nullptr
 Points to the end of the buffer. More...
 
std::vector< StringRefNameTable
 Function name table. More...
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileReader
SampleProfileMap Profiles
 Map every function to its associated profile. More...
 
LLVMContextCtx
 LLVM context used to emit diagnostics. More...
 
std::unique_ptr< MemoryBufferBuffer
 Memory buffer holding the profile file. More...
 
std::unordered_set< std::string > MD5NameBuffer
 Extra name buffer holding names created on demand. More...
 
std::unique_ptr< ProfileSummarySummary
 Profile summary information. More...
 
std::unique_ptr< SampleProfileReaderItaniumRemapperRemapper
 
bool ProfileIsProbeBased = false
 Whether samples are collected based on pseudo probes. More...
 
bool ProfileIsCS = false
 Whether function profiles are context-sensitive. More...
 
uint32_t CSProfileCount = 0
 Number of context-sensitive profiles. More...
 
bool ProfileIsFS = false
 Whether the function profiles use FS discriminators. More...
 
SampleProfileFormat Format = SPF_None
 The format of sample. More...
 
const ModuleM = nullptr
 The current module being compiled if SampleProfileReader is used by compiler. More...
 
uint32_t MaskedBitFrom = 31
 Zero out the discriminator bits higher than bit MaskedBitFrom (0 based). More...
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
static ErrorOr< std::unique_ptr< SampleProfileReader > > create (const std::string Filename, LLVMContext &C, FSDiscriminatorPass P=FSDiscriminatorPass::Base, const std::string RemapFilename="")
 Create a sample profile reader appropriate to the file format. More...
 
static ErrorOr< std::unique_ptr< SampleProfileReader > > create (std::unique_ptr< MemoryBuffer > &B, LLVMContext &C, FSDiscriminatorPass P=FSDiscriminatorPass::Base, const std::string RemapFilename="")
 Create a sample profile reader from the supplied memory buffer. More...
 
- Static Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
static std::unique_ptr< ProfileSummarytakeSummary (SampleProfileReader &Reader)
 Take ownership of the summary of this reader. More...
 

Detailed Description

Definition at line 578 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileReaderBinary()

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

Definition at line 580 of file SampleProfReader.h.

Member Function Documentation

◆ at_eof()

bool llvm::sampleprof::SampleProfileReaderBinary::at_eof ( ) const
inlineprotected

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

Definition at line 619 of file SampleProfReader.h.

References Data, and End.

Referenced by readImpl().

◆ getNameTable()

virtual std::vector<StringRef>* llvm::sampleprof::SampleProfileReaderBinary::getNameTable ( )
inlineoverridevirtual

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

Reimplemented from llvm::sampleprof::SampleProfileReader.

Definition at line 592 of file SampleProfReader.h.

References NameTable.

◆ readFuncProfile()

std::error_code SampleProfileReaderBinary::readFuncProfile ( const uint8_t *  Start)
protected

Read the next function profile instance.

Definition at line 582 of file SampleProfReader.cpp.

Referenced by readImpl(), and llvm::sampleprof::SampleProfileReaderCompactBinary::readImpl().

◆ readHeader()

std::error_code SampleProfileReaderBinary::readHeader ( )
overridevirtual

◆ readImpl()

std::error_code SampleProfileReaderBinary::readImpl ( )
overridevirtual

◆ readMagicIdent()

std::error_code SampleProfileReaderBinary::readMagicIdent ( )
protected

◆ readNameTable()

std::error_code SampleProfileReaderBinary::readNameTable ( )
protectedvirtual

◆ readNumber()

template<typename T >
ErrorOr< T > SampleProfileReaderBinary::readNumber
protected

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.

Returns
the read value.

Definition at line 387 of file SampleProfReader.cpp.

References Data, llvm::decodeULEB128(), End, llvm::malformed, llvm::max(), llvm::sampleprof::SampleProfileReader::reportError(), llvm::success, and llvm::truncated.

◆ readProfile()

std::error_code SampleProfileReaderBinary::readProfile ( FunctionSamples FProfile)
protected

◆ readSampleContextFromTable()

ErrorOr< SampleContext > SampleProfileReaderBinary::readSampleContextFromTable ( )
protectedvirtual

◆ readString()

ErrorOr< StringRef > SampleProfileReaderBinary::readString ( )
protected

Read a string from the profile.

If an error occurs during decoding, a diagnostic message is emitted and EC is set.

Returns
the read value.

Definition at line 408 of file SampleProfReader.cpp.

References Data, End, llvm::sampleprof::SampleProfileReader::reportError(), and llvm::truncated.

Referenced by readNameTable().

◆ readStringFromTable()

ErrorOr< StringRef > SampleProfileReaderBinary::readStringFromTable ( )
protectedvirtual

◆ readStringIndex()

template<typename T >
ErrorOr< uint32_t > SampleProfileReaderBinary::readStringIndex ( T Table)
inlineprotected

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

Definition at line 437 of file SampleProfReader.cpp.

References llvm::truncated_name_table.

Referenced by readStringFromTable(), and llvm::sampleprof::SampleProfileReaderExtBinaryBase::readStringFromTable().

◆ readSummary()

std::error_code SampleProfileReaderBinary::readSummary ( )
protected

Read profile summary.

Definition at line 1360 of file SampleProfReader.cpp.

Referenced by readHeader().

◆ readUnencodedNumber()

template<typename T >
ErrorOr< T > SampleProfileReaderBinary::readUnencodedNumber
protected

Read a numeric value of type T from the profile.

The value is saved without encoded.

Definition at line 422 of file SampleProfReader.cpp.

References Data, End, llvm::sampleprof::SampleProfileReader::reportError(), support(), and llvm::truncated.

Member Data Documentation

◆ Data

const uint8_t* llvm::sampleprof::SampleProfileReaderBinary::Data = nullptr
protected

◆ End

const uint8_t* llvm::sampleprof::SampleProfileReaderBinary::End = nullptr
protected

◆ NameTable

std::vector<StringRef> llvm::sampleprof::SampleProfileReaderBinary::NameTable
protected

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