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

#include "llvm/ProfileData/SampleProfWriter.h"

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

Public Member Functions

virtual std::error_code write (const SampleProfileMap &ProfileMap) override
 Write all the sample profiles in the given map of samples. More...
 
virtual void setToCompressAllSections () override
 
void setToCompressSection (SecType Type)
 
virtual std::error_code writeSample (const FunctionSamples &S) override
 Write samples of a top-level function to a binary file. More...
 
virtual void setUseMD5 () override
 
virtual void setPartialProfile () override
 
virtual void setProfileSymbolList (ProfileSymbolList *PSL) override
 
virtual void resetSecLayout (SectionLayout SL) override
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileWriterBinary
 SampleProfileWriterBinary (std::unique_ptr< raw_ostream > &OS)
 
- Public Member Functions inherited from llvm::sampleprof::SampleProfileWriter
virtual ~SampleProfileWriter ()=default
 
raw_ostreamgetOutputStream ()
 

Protected Member Functions

uint64_t markSectionStart (SecType Type, uint32_t LayoutIdx)
 Return the current position and prepare to use it as the start position of a section given the section type Type and its position LayoutIdx in SectionHdrLayout. More...
 
std::error_code addNewSection (SecType Sec, uint32_t LayoutIdx, uint64_t SectionStart)
 Add a new section into section header table given the section type Type, its position LayoutIdx in SectionHdrLayout and the location SectionStart where the section should be written to. More...
 
template<class SecFlagType >
void addSectionFlag (SecType Type, SecFlagType Flag)
 
template<class SecFlagType >
void addSectionFlag (uint32_t SectionIdx, SecFlagType Flag)
 
virtual void addContext (const SampleContext &Context) override
 
virtual std::error_code writeCustomSection (SecType Type)=0
 
virtual void verifySecLayout (SectionLayout SL)=0
 
virtual std::error_code writeSections (const SampleProfileMap &ProfileMap)=0
 
virtual std::error_code writeOneSection (SecType Type, uint32_t LayoutIdx, const SampleProfileMap &ProfileMap)
 
virtual std::error_code writeNameTable () override
 
virtual std::error_code writeContextIdx (const SampleContext &Context) override
 
std::error_code writeCSNameIdx (const SampleContext &Context)
 
std::error_code writeCSNameTableSection ()
 
std::error_code writeFuncMetadata (const SampleProfileMap &Profiles)
 
std::error_code writeFuncMetadata (const FunctionSamples &Profile)
 
std::error_code writeNameTableSection (const SampleProfileMap &ProfileMap)
 
std::error_code writeFuncOffsetTable ()
 
std::error_code writeProfileSymbolListSection ()
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileWriterBinary
virtual MapVector< StringRef, uint32_t > & getNameTable ()
 
virtual std::error_code writeMagicIdent (SampleProfileFormat Format)
 
std::error_code writeSummary ()
 
std::error_code writeNameIdx (StringRef FName)
 
std::error_code writeBody (const FunctionSamples &S)
 
void stablizeNameTable (MapVector< StringRef, uint32_t > &NameTable, std::set< StringRef > &V)
 
void addName (StringRef FName)
 
void addNames (const FunctionSamples &S)
 
- Protected Member Functions inherited from llvm::sampleprof::SampleProfileWriter
 SampleProfileWriter (std::unique_ptr< raw_ostream > &OS)
 
virtual std::error_code writeFuncProfiles (const SampleProfileMap &ProfileMap)
 
void computeSummary (const SampleProfileMap &ProfileMap)
 Compute summary for this profile. More...
 

Protected Attributes

SectionLayout SecLayout = DefaultLayout
 
SmallVector< SecHdrTableEntry, 8 > SectionHdrLayout
 
uint64_t SecLBRProfileStart = 0
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileWriterBinary
MapVector< StringRef, uint32_tNameTable
 
- Protected Attributes inherited from llvm::sampleprof::SampleProfileWriter
std::unique_ptr< raw_ostreamOutputStream
 Output stream where to emit the profile to. More...
 
std::unique_ptr< ProfileSummarySummary
 Profile summary. More...
 
SampleProfileFormat Format = SPF_None
 Profile format. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::sampleprof::SampleProfileWriter
static ErrorOr< std::unique_ptr< SampleProfileWriter > > create (StringRef Filename, SampleProfileFormat Format)
 Profile writer factory. More...
 
static ErrorOr< std::unique_ptr< SampleProfileWriter > > create (std::unique_ptr< raw_ostream > &OS, SampleProfileFormat Format)
 Create a new stream writer based on the value of Format. More...
 

Detailed Description

Definition at line 187 of file SampleProfWriter.h.

Member Function Documentation

◆ addContext()

void SampleProfileWriterExtBinaryBase::addContext ( const SampleContext Context)
overrideprotectedvirtual

◆ addNewSection()

std::error_code SampleProfileWriterExtBinaryBase::addNewSection ( SecType  Sec,
uint32_t  LayoutIdx,
uint64_t  SectionStart 
)
protected

Add a new section into section header table given the section type Type, its position LayoutIdx in SectionHdrLayout and the location SectionStart where the section should be written to.

Definition at line 101 of file SampleProfWriter.cpp.

References assert(), and SectionHdrLayout.

Referenced by writeOneSection().

◆ addSectionFlag() [1/2]

template<class SecFlagType >
void llvm::sampleprof::SampleProfileWriterExtBinaryBase::addSectionFlag ( SecType  Type,
SecFlagType  Flag 
)
inlineprotected

◆ addSectionFlag() [2/2]

template<class SecFlagType >
void llvm::sampleprof::SampleProfileWriterExtBinaryBase::addSectionFlag ( uint32_t  SectionIdx,
SecFlagType  Flag 
)
inlineprotected

Definition at line 241 of file SampleProfWriter.h.

References llvm::sampleprof::addSecFlag(), and SectionHdrLayout.

◆ markSectionStart()

uint64_t SampleProfileWriterExtBinaryBase::markSectionStart ( SecType  Type,
uint32_t  LayoutIdx 
)
protected

Return the current position and prepare to use it as the start position of a section given the section type Type and its position LayoutIdx in SectionHdrLayout.

Definition at line 68 of file SampleProfWriter.cpp.

References assert(), llvm::sampleprof::SampleProfileWriter::OutputStream, and SectionHdrLayout.

Referenced by writeOneSection().

◆ resetSecLayout()

virtual void llvm::sampleprof::SampleProfileWriterExtBinaryBase::resetSecLayout ( SectionLayout  SL)
inlineoverridevirtual

Reimplemented from llvm::sampleprof::SampleProfileWriter.

Definition at line 216 of file SampleProfWriter.h.

References verifySecLayout().

◆ setPartialProfile()

virtual void llvm::sampleprof::SampleProfileWriterExtBinaryBase::setPartialProfile ( )
inlineoverridevirtual

◆ setProfileSymbolList()

virtual void llvm::sampleprof::SampleProfileWriterExtBinaryBase::setProfileSymbolList ( ProfileSymbolList PSL)
inlineoverridevirtual

Reimplemented from llvm::sampleprof::SampleProfileWriter.

Definition at line 212 of file SampleProfWriter.h.

◆ setToCompressAllSections()

void SampleProfileWriterExtBinaryBase::setToCompressAllSections ( )
overridevirtual

Reimplemented from llvm::sampleprof::SampleProfileWriter.

Definition at line 669 of file SampleProfWriter.cpp.

◆ setToCompressSection()

void SampleProfileWriterExtBinaryBase::setToCompressSection ( SecType  Type)

Definition at line 674 of file SampleProfWriter.cpp.

References addSectionFlag(), and llvm::sampleprof::SecFlagCompress.

Referenced by writeOneSection().

◆ setUseMD5()

virtual void llvm::sampleprof::SampleProfileWriterExtBinaryBase::setUseMD5 ( )
inlineoverridevirtual

◆ verifySecLayout()

virtual void llvm::sampleprof::SampleProfileWriterExtBinaryBase::verifySecLayout ( SectionLayout  SL)
protectedpure virtual

Referenced by resetSecLayout().

◆ write()

std::error_code SampleProfileWriterExtBinaryBase::write ( const SampleProfileMap ProfileMap)
overridevirtual

Write all the sample profiles in the given map of samples.

Returns
status code of the file update operation.

Reimplemented from llvm::sampleprof::SampleProfileWriter.

Definition at line 117 of file SampleProfWriter.cpp.

References llvm::success, and writeSections().

◆ writeContextIdx()

std::error_code SampleProfileWriterExtBinaryBase::writeContextIdx ( const SampleContext Context)
overrideprotectedvirtual

◆ writeCSNameIdx()

std::error_code SampleProfileWriterExtBinaryBase::writeCSNameIdx ( const SampleContext Context)
protected

◆ writeCSNameTableSection()

std::error_code SampleProfileWriterExtBinaryBase::writeCSNameTableSection ( )
protected

◆ writeCustomSection()

virtual std::error_code llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCustomSection ( SecType  Type)
protectedpure virtual

Referenced by writeOneSection().

◆ writeFuncMetadata() [1/2]

std::error_code SampleProfileWriterExtBinaryBase::writeFuncMetadata ( const FunctionSamples Profile)
protected

◆ writeFuncMetadata() [2/2]

std::error_code SampleProfileWriterExtBinaryBase::writeFuncMetadata ( const SampleProfileMap Profiles)
protected

◆ writeFuncOffsetTable()

std::error_code SampleProfileWriterExtBinaryBase::writeFuncOffsetTable ( )
protected

◆ writeNameTable()

std::error_code SampleProfileWriterExtBinaryBase::writeNameTable ( )
overrideprotectedvirtual

◆ writeNameTableSection()

std::error_code SampleProfileWriterExtBinaryBase::writeNameTableSection ( const SampleProfileMap ProfileMap)
protected

◆ writeOneSection()

std::error_code SampleProfileWriterExtBinaryBase::writeOneSection ( SecType  Type,
uint32_t  LayoutIdx,
const SampleProfileMap ProfileMap 
)
protectedvirtual

◆ writeProfileSymbolListSection()

std::error_code SampleProfileWriterExtBinaryBase::writeProfileSymbolListSection ( )
protected

◆ writeSample()

std::error_code SampleProfileWriterExtBinaryBase::writeSample ( const FunctionSamples S)
overridevirtual

Write samples of a top-level function to a binary file.

Returns
true if the samples were written successfully, false otherwise.

Reimplemented from llvm::sampleprof::SampleProfileWriterBinary.

Definition at line 150 of file SampleProfWriter.cpp.

References Context, llvm::encodeULEB128(), llvm::sampleprof::SampleProfileWriter::OutputStream, S, SecLBRProfileStart, and llvm::sampleprof::SampleProfileWriterBinary::writeBody().

◆ writeSections()

virtual std::error_code llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeSections ( const SampleProfileMap ProfileMap)
protectedpure virtual

Referenced by write().

Member Data Documentation

◆ SecLayout

SectionLayout llvm::sampleprof::SampleProfileWriterExtBinaryBase::SecLayout = DefaultLayout
protected

Definition at line 275 of file SampleProfWriter.h.

◆ SecLBRProfileStart

uint64_t llvm::sampleprof::SampleProfileWriterExtBinaryBase::SecLBRProfileStart = 0
protected

Definition at line 286 of file SampleProfWriter.h.

Referenced by writeOneSection(), and writeSample().

◆ SectionHdrLayout

SmallVector<SecHdrTableEntry, 8> llvm::sampleprof::SampleProfileWriterExtBinaryBase::SectionHdrLayout
protected
Initial value:

Definition at line 280 of file SampleProfWriter.h.

Referenced by addNewSection(), addSectionFlag(), and markSectionStart().


The documentation for this class was generated from the following files:
llvm::sampleprof::DefaultLayout
@ DefaultLayout
Definition: SampleProfWriter.h:30
llvm::sampleprof::ExtBinaryHdrLayoutTable
const std::array< SmallVector< SecHdrTableEntry, 8 >, NumOfLayout > ExtBinaryHdrLayoutTable
Definition: SampleProfWriter.h:157