LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::sampleprof::SampleProfileReaderText Class Reference

#include "llvm/ProfileData/SampleProfReader.h"

Inheritance diagram for llvm::sampleprof::SampleProfileReaderText:
Inheritance graph
[legend]

Public Member Functions

 SampleProfileReaderText (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.
 
void setProfileUseMD5 () override
 Text format sample profile does not support MD5 for now.
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileReader
 SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None)
 
virtual ~SampleProfileReader ()=default
 
virtual std::error_code readHeader ()=0
 Read and validate the file header.
 
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.
 
virtual std::error_code readImpl ()=0
 The implementaion to read sample profiles from the associated file.
 
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.
 
void dump (raw_ostream &OS=dbgs())
 Print all the profiles on stream OS.
 
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 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 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.
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
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.
 
- Static Protected Member Functions inherited from llvm::sampleprof::SampleProfileReader
static std::unique_ptr< ProfileSummarytakeSummary (SampleProfileReader &Reader)
 Take ownership of the summary of this reader.
 
- 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.
 
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.
 

Detailed Description

Definition at line 611 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileReaderText()

llvm::sampleprof::SampleProfileReaderText::SampleProfileReaderText ( std::unique_ptr< MemoryBuffer B,
LLVMContext C 
)
inline

Definition at line 613 of file SampleProfReader.h.

Member Function Documentation

◆ hasFormat()

bool SampleProfileReaderText::hasFormat ( const MemoryBuffer Buffer)
static

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

Definition at line 477 of file SampleProfReader.cpp.

References llvm::sampleprof::SampleProfileReader::Buffer, llvm::line_iterator::is_at_eof(), and ParseHead().

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

◆ readHeader()

std::error_code llvm::sampleprof::SampleProfileReaderText::readHeader ( )
inlineoverridevirtual

Read and validate the file header.

Implements llvm::sampleprof::SampleProfileReader.

Definition at line 617 of file SampleProfReader.h.

References llvm::success.

◆ readImpl()

std::error_code SampleProfileReaderText::readImpl ( )
overridevirtual

Read sample profiles from the associated file.

Load samples from a text file.

See the documentation at the top of the file for an explanation of the expected format.

Returns
true if the file was loaded successfully, false otherwise.

Implements llvm::sampleprof::SampleProfileReader.

Definition at line 325 of file SampleProfReader.cpp.

References llvm::sampleprof::FunctionSamples::addBodySamples(), llvm::sampleprof::FunctionSamples::addCalledTargetSamples(), llvm::sampleprof::FunctionSamples::addHeadSamples(), llvm::sampleprof::FunctionSamples::addTotalSamples(), assert(), Attributes, llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::sampleprof::SampleProfileReader::Buffer, llvm::SmallVectorImpl< T >::clear(), llvm::sampleprof::SampleProfileReader::computeSummary(), llvm::sampleprof::ContextShouldBeInlined, llvm::sampleprof::SampleProfileMap::create(), llvm::sampleprof::SampleProfileReader::CSProfileCount, llvm::sampleprof::SampleProfileReader::Ctx, llvm::Depth, llvm::LLVMContext::diagnose(), llvm::DS_Warning, llvm::sampleprof::SampleProfileMap::erase(), llvm::StringRef::find_first_not_of(), llvm::sampleprof::FunctionSamples::getContext(), llvm::sampleprof::SampleProfileReader::getDiscriminatorMask(), llvm::sampleprof::SampleContext::hasContext(), llvm::line_iterator::is_at_eof(), llvm::line_iterator::line_number(), llvm::malformed, llvm::mergeSampleProfErrors(), llvm::StringRef::npos, ParseHead(), ParseLine(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::SampleProfileReader::ProfileIsCS, llvm::sampleprof::FunctionSamples::ProfileIsFS, llvm::sampleprof::SampleProfileReader::ProfileIsFS, ProfileIsFSDisciminator, llvm::sampleprof::FunctionSamples::ProfileIsPreInlined, llvm::sampleprof::SampleProfileReader::ProfileIsPreInlined, llvm::sampleprof::FunctionSamples::ProfileIsProbeBased, llvm::sampleprof::SampleProfileReader::ProfileIsProbeBased, llvm::sampleprof::SampleProfileReader::Profiles, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::sampleprof::SampleProfileReader::reportError(), llvm::sampleprof::SampleContext::setAllAttributes(), llvm::sampleprof::FunctionSamples::setFunction(), llvm::sampleprof::FunctionSamples::setFunctionHash(), llvm::SmallVectorBase< Size_T >::size(), llvm::sampleprof::SampleProfileReader::SkipFlatProf, and llvm::success.

◆ setProfileUseMD5()

void llvm::sampleprof::SampleProfileReaderText::setProfileUseMD5 ( )
inlineoverridevirtual

Text format sample profile does not support MD5 for now.

Reimplemented from llvm::sampleprof::SampleProfileReader.

Definition at line 626 of file SampleProfReader.h.


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