LLVM 20.0.0git
|
#include "llvm/ProfileData/SampleProfWriter.h"
Public Member Functions | |
std::error_code | write (const SampleProfileMap &ProfileMap) override |
Write all the sample profiles in the given map of samples. | |
void | setToCompressAllSections () override |
void | setToCompressSection (SecType Type) |
std::error_code | writeSample (const FunctionSamples &S) override |
Write samples of a top-level function to a binary file. | |
void | setUseMD5 () override |
void | setPartialProfile () override |
void | setProfileSymbolList (ProfileSymbolList *PSL) override |
void | setUseCtxSplitLayout () override |
void | resetSecLayout (SectionLayout SL) |
Public Member Functions inherited from llvm::sampleprof::SampleProfileWriterBinary | |
SampleProfileWriterBinary (std::unique_ptr< raw_ostream > &OS) | |
std::error_code | writeSample (const FunctionSamples &S) override |
Write samples of a top-level function to a binary file. | |
Public Member Functions inherited from llvm::sampleprof::SampleProfileWriter | |
virtual | ~SampleProfileWriter ()=default |
virtual std::error_code | writeSample (const FunctionSamples &S)=0 |
Write sample profiles in S . | |
virtual std::error_code | write (const SampleProfileMap &ProfileMap) |
Write all the sample profiles in the given map of samples. | |
template<typename FunctionPruningStrategy = DefaultFunctionPruningStrategy> | |
std::error_code | writeWithSizeLimit (SampleProfileMap &ProfileMap, size_t OutputSizeLimit) |
Write sample profiles up to given size limit, using the pruning strategy to drop some functions if necessary. | |
raw_ostream & | getOutputStream () |
virtual void | setProfileSymbolList (ProfileSymbolList *PSL) |
virtual void | setToCompressAllSections () |
virtual void | setUseMD5 () |
virtual void | setPartialProfile () |
virtual void | setUseCtxSplitLayout () |
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. | |
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. | |
template<class SecFlagType > | |
void | addSectionFlag (SecType Type, SecFlagType Flag) |
template<class SecFlagType > | |
void | addSectionFlag (uint32_t SectionIdx, SecFlagType Flag) |
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) |
std::error_code | writeNameTable () override |
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< FunctionId, uint32_t > & | getNameTable () |
virtual std::error_code | writeMagicIdent (SampleProfileFormat Format) |
virtual std::error_code | writeNameTable () |
std::error_code | writeHeader (const SampleProfileMap &ProfileMap) override |
Write a file header for the profile file. | |
std::error_code | writeSummary () |
virtual std::error_code | writeContextIdx (const SampleContext &Context) |
std::error_code | writeNameIdx (FunctionId FName) |
std::error_code | writeBody (const FunctionSamples &S) |
void | stablizeNameTable (MapVector< FunctionId, uint32_t > &NameTable, std::set< FunctionId > &V) |
void | addName (FunctionId FName) |
virtual void | addContext (const SampleContext &Context) |
void | addNames (const FunctionSamples &S) |
Protected Member Functions inherited from llvm::sampleprof::SampleProfileWriter | |
SampleProfileWriter (std::unique_ptr< raw_ostream > &OS) | |
virtual std::error_code | writeHeader (const SampleProfileMap &ProfileMap)=0 |
Write a file header for the profile file. | |
virtual std::error_code | writeFuncProfiles (const SampleProfileMap &ProfileMap) |
std::error_code | writeWithSizeLimitInternal (SampleProfileMap &ProfileMap, size_t OutputSizeLimit, FunctionPruningStrategy *Strategy) |
void | computeSummary (const SampleProfileMap &ProfileMap) |
Compute summary for this profile. | |
Protected Attributes | |
SectionLayout | SecLayout = DefaultLayout |
SmallVector< SecHdrTableEntry, 8 > | SectionHdrLayout |
uint64_t | SecLBRProfileStart = 0 |
Protected Attributes inherited from llvm::sampleprof::SampleProfileWriterBinary | |
MapVector< FunctionId, uint32_t > | NameTable |
Protected Attributes inherited from llvm::sampleprof::SampleProfileWriter | |
size_t | LineCount |
For writeWithSizeLimit in text mode, each newline takes 1 additional byte on Windows when actually written to the file, but not written to a memory buffer. | |
std::unique_ptr< raw_ostream > | OutputStream |
Output stream where to emit the profile to. | |
std::unique_ptr< ProfileSummary > | Summary |
Profile summary. | |
SampleProfileFormat | Format = SPF_None |
Profile format. | |
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. | |
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 . | |
Definition at line 267 of file SampleProfWriter.h.
|
overrideprotectedvirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriterBinary.
Definition at line 672 of file SampleProfWriter.cpp.
References llvm::sampleprof::SampleProfileWriterBinary::addName(), llvm::sampleprof::SampleContext::getContextFrames(), llvm::sampleprof::SampleContext::getFunction(), and llvm::sampleprof::SampleContext::hasContext().
Referenced by writeNameTableSection().
|
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 199 of file SampleProfWriter.cpp.
References assert(), llvm::sampleprof::hasSecFlag(), llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::SecFlagCompress, SectionHdrLayout, and llvm::success.
Referenced by writeOneSection().
|
inlineprotected |
Definition at line 318 of file SampleProfWriter.h.
References llvm::sampleprof::addSecFlag(), and SectionHdrLayout.
Referenced by setPartialProfile(), setToCompressSection(), setUseMD5(), writeFuncOffsetTable(), writeNameTableSection(), and writeOneSection().
|
inlineprotected |
Definition at line 325 of file SampleProfWriter.h.
References llvm::sampleprof::addSecFlag(), and SectionHdrLayout.
|
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 165 of file SampleProfWriter.cpp.
References assert(), llvm::sampleprof::hasSecFlag(), llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::SecFlagCompress, and SectionHdrLayout.
Referenced by writeOneSection().
|
inline |
Definition at line 300 of file SampleProfWriter.h.
References assert(), llvm::sampleprof::ExtBinaryHdrLayoutTable, SecLayout, SectionHdrLayout, and verifySecLayout().
Referenced by setUseCtxSplitLayout().
|
inlineoverridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 288 of file SampleProfWriter.h.
References addSectionFlag(), llvm::sampleprof::SecFlagPartial, and llvm::sampleprof::SecProfSummary.
|
inlineoverridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 292 of file SampleProfWriter.h.
|
overridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 738 of file SampleProfWriter.cpp.
References llvm::sampleprof::addSecFlag(), llvm::sampleprof::SecFlagCompress, and SectionHdrLayout.
void SampleProfileWriterExtBinaryBase::setToCompressSection | ( | SecType | Type | ) |
Definition at line 743 of file SampleProfWriter.cpp.
References addSectionFlag(), and llvm::sampleprof::SecFlagCompress.
Referenced by writeOneSection().
|
inlineoverridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 296 of file SampleProfWriter.h.
References llvm::sampleprof::CtxSplitLayout, and resetSecLayout().
|
inlineoverridevirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 277 of file SampleProfWriter.h.
References addSectionFlag(), llvm::sampleprof::SecFlagFixedLengthMD5, llvm::sampleprof::SecFlagMD5Name, and llvm::sampleprof::SecNameTable.
|
protectedpure virtual |
Referenced by resetSecLayout().
|
overridevirtual |
Write all the sample profiles in the given map of samples.
Reimplemented from llvm::sampleprof::SampleProfileWriter.
Definition at line 215 of file SampleProfWriter.cpp.
References llvm::sampleprof::SampleProfileWriterBinary::NameTable, llvm::success, and writeSections().
|
overrideprotectedvirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriterBinary.
Definition at line 236 of file SampleProfWriter.cpp.
References llvm::sampleprof::SampleContext::getFunction(), llvm::sampleprof::SampleContext::hasContext(), writeCSNameIdx(), and llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx().
Referenced by writeFuncMetadata(), and writeFuncOffsetTable().
|
protected |
Definition at line 245 of file SampleProfWriter.cpp.
References llvm::encodeULEB128(), llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::success, and llvm::truncated_name_table.
Referenced by writeContextIdx().
|
protected |
Definition at line 385 of file SampleProfWriter.cpp.
References assert(), llvm::encodeULEB128(), I, llvm::little, OS, llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::success, and llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx().
Referenced by writeOneSection().
|
protectedpure virtual |
Referenced by writeOneSection().
|
protected |
Definition at line 298 of file SampleProfWriter.cpp.
References llvm::sampleprof::LineLocation::Discriminator, llvm::encodeULEB128(), llvm::sampleprof::SampleContext::getAllAttributes(), llvm::sampleprof::FunctionSamples::getCallsiteSamples(), llvm::sampleprof::FunctionSamples::getContext(), llvm::sampleprof::FunctionSamples::getFunctionHash(), llvm::sampleprof::LineLocation::LineOffset, OS, llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::FunctionSamples::ProfileIsPreInlined, llvm::sampleprof::FunctionSamples::ProfileIsProbeBased, llvm::success, writeContextIdx(), and writeFuncMetadata().
|
protected |
Definition at line 330 of file SampleProfWriter.cpp.
References llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::FunctionSamples::ProfileIsPreInlined, llvm::sampleprof::FunctionSamples::ProfileIsProbeBased, llvm::success, and writeFuncMetadata().
Referenced by writeFuncMetadata(), and writeOneSection().
|
protected |
Definition at line 262 of file SampleProfWriter.cpp.
References addSectionFlag(), llvm::encodeULEB128(), llvm::Offset, OS, llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::SecFlagOrdered, llvm::sampleprof::SecFuncOffsetTable, llvm::success, and writeContextIdx().
Referenced by writeOneSection().
|
overrideprotectedvirtual |
Reimplemented from llvm::sampleprof::SampleProfileWriterBinary.
Definition at line 342 of file SampleProfWriter.cpp.
References llvm::encodeULEB128(), llvm::little, N, llvm::sampleprof::SampleProfileWriterBinary::NameTable, OS, llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::SampleProfileWriterBinary::stablizeNameTable(), llvm::success, llvm::support::endian::Writer::write(), and llvm::sampleprof::SampleProfileWriterBinary::writeNameTable().
Referenced by writeNameTableSection().
|
protected |
Definition at line 360 of file SampleProfWriter.cpp.
References addContext(), llvm::sampleprof::SampleProfileWriterBinary::addNames(), addSectionFlag(), I, llvm::sampleprof::SampleProfileWriterBinary::NameTable, llvm::sampleprof::SecFlagUniqSuffix, llvm::sampleprof::SecNameTable, llvm::success, llvm::sampleprof::FunctionSamples::UniqSuffix, and writeNameTable().
Referenced by writeOneSection().
|
protectedvirtual |
Definition at line 422 of file SampleProfWriter.cpp.
References addNewSection(), addSectionFlag(), llvm::sampleprof::SampleProfileWriter::computeSummary(), markSectionStart(), llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::FunctionSamples::ProfileIsFS, llvm::sampleprof::FunctionSamples::ProfileIsPreInlined, llvm::sampleprof::FunctionSamples::ProfileIsProbeBased, llvm::sampleprof::SecCSNameTable, llvm::sampleprof::SecFlagFSDiscriminator, llvm::sampleprof::SecFlagFullContext, llvm::sampleprof::SecFlagHasAttribute, llvm::sampleprof::SecFlagIsPreInlined, llvm::sampleprof::SecFlagIsProbeBased, llvm::sampleprof::SecFuncMetadata, llvm::sampleprof::SecFuncOffsetTable, llvm::sampleprof::SecLBRProfile, SecLBRProfileStart, llvm::sampleprof::SecNameTable, llvm::sampleprof::SecProfileSymbolList, llvm::sampleprof::SecProfSummary, setToCompressSection(), llvm::success, llvm::sampleprof::ProfileSymbolList::toCompress(), writeCSNameTableSection(), writeCustomSection(), writeFuncMetadata(), writeFuncOffsetTable(), llvm::sampleprof::SampleProfileWriter::writeFuncProfiles(), writeNameTableSection(), writeProfileSymbolListSection(), and llvm::sampleprof::SampleProfileWriterBinary::writeSummary().
|
protected |
Definition at line 414 of file SampleProfWriter.cpp.
References llvm::sampleprof::SampleProfileWriter::OutputStream, llvm::sampleprof::ProfileSymbolList::size(), llvm::success, and llvm::sampleprof::ProfileSymbolList::write().
Referenced by writeOneSection().
|
overridevirtual |
Write samples of a top-level function to a binary file.
Reimplemented from llvm::sampleprof::SampleProfileWriterBinary.
Definition at line 254 of file SampleProfWriter.cpp.
References llvm::encodeULEB128(), llvm::sampleprof::FunctionSamples::getContext(), llvm::sampleprof::FunctionSamples::getHeadSamples(), llvm::Offset, llvm::sampleprof::SampleProfileWriter::OutputStream, SecLBRProfileStart, and llvm::sampleprof::SampleProfileWriterBinary::writeBody().
|
protectedpure virtual |
Referenced by write().
|
protected |
Definition at line 358 of file SampleProfWriter.h.
Referenced by resetSecLayout().
|
protected |
Definition at line 369 of file SampleProfWriter.h.
Referenced by writeOneSection(), and writeSample().
|
protected |
Definition at line 363 of file SampleProfWriter.h.
Referenced by addNewSection(), addSectionFlag(), markSectionStart(), resetSecLayout(), and setToCompressAllSections().