LLVM 20.0.0git
|
Sample-based profile writer. Base class. More...
#include "llvm/ProfileData/SampleProfWriter.h"
Public Member Functions | |
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 () |
Static Public Member Functions | |
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 . | |
Protected Member Functions | |
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 | |
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. | |
Sample-based profile writer. Base class.
Definition at line 89 of file SampleProfWriter.h.
|
virtualdefault |
|
inlineprotected |
Definition at line 134 of file SampleProfWriter.h.
|
protected |
Compute summary for this profile.
Definition at line 933 of file SampleProfWriter.cpp.
References llvm::SampleProfileSummaryBuilder::computeSummaryForProfiles(), llvm::ProfileSummaryBuilder::DefaultCutoffs, and Summary.
Referenced by llvm::sampleprof::SampleProfileWriterBinary::writeHeader(), and llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeOneSection().
|
static |
Create a new stream writer based on the value of Format
.
Create a sample profile stream writer based on the specified format.
For testing.
OS | The output stream to store the profile data to. |
Format | Encoding format for the profile file. |
Definition at line 905 of file SampleProfWriter.cpp.
References Format, OS, llvm::sampleprof::FunctionSamples::ProfileIsCS, llvm::sampleprof::FunctionSamples::ProfileIsProbeBased, llvm::sampleprof::SPF_Binary, llvm::sampleprof::SPF_Ext_Binary, llvm::sampleprof::SPF_GCC, llvm::sampleprof::SPF_Text, llvm::unrecognized_format, and llvm::unsupported_writing_format.
|
static |
Profile writer factory.
Create a sample profile file writer based on the specified format.
Create a new file writer based on the value of Format
.
Filename | The file to create. |
Format | Encoding format for the profile file. |
Definition at line 884 of file SampleProfWriter.cpp.
References create(), Format, llvm::sys::fs::OF_None, llvm::sys::fs::OF_TextWithCRLF, OS, llvm::sampleprof::SPF_Binary, and llvm::sampleprof::SPF_Ext_Binary.
Referenced by create().
|
inline |
Definition at line 114 of file SampleProfWriter.h.
References OutputStream.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 130 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 127 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 128 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterText, and llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 131 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 129 of file SampleProfWriter.h.
|
virtual |
Write all the sample profiles in the given map of samples.
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 151 of file SampleProfWriter.cpp.
References llvm::success, writeFuncProfiles(), and writeHeader().
Referenced by writeWithSizeLimitInternal().
|
protectedvirtual |
Definition at line 141 of file SampleProfWriter.cpp.
References I, llvm::sampleprof::sortFuncProfiles(), llvm::success, and writeSample().
Referenced by write(), and llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeOneSection().
|
protectedpure virtual |
Write a file header for the profile file.
Implemented in llvm::sampleprof::SampleProfileWriterText, and llvm::sampleprof::SampleProfileWriterBinary.
Referenced by write().
|
pure virtual |
Write sample profiles in S
.
Implemented in llvm::sampleprof::SampleProfileWriterText, llvm::sampleprof::SampleProfileWriterBinary, and llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Referenced by writeFuncProfiles().
|
inline |
Write sample profiles up to given size limit, using the pruning strategy to drop some functions if necessary.
Definition at line 108 of file SampleProfWriter.h.
References writeWithSizeLimitInternal().
|
protected |
Definition at line 90 of file SampleProfWriter.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::dbgs(), llvm::sampleprof::FunctionPruningStrategy::Erase(), Format, LineCount, LLVM_DEBUG, OutputStream, llvm::SmallVectorBase< Size_T >::size(), llvm::sampleprof::SPF_Text, llvm::success, llvm::too_large, and write().
Referenced by writeWithSizeLimit().
|
protected |
Profile format.
Definition at line 162 of file SampleProfWriter.h.
Referenced by create(), llvm::sampleprof::SampleProfileWriterBinary::writeHeader(), llvm::sampleprof::SampleProfileWriterBinary::writeMagicIdent(), and writeWithSizeLimitInternal().
|
protected |
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.
This needs to be accounted for when rewriting the profile.
Definition at line 150 of file SampleProfWriter.h.
Referenced by llvm::sampleprof::SampleProfileWriterText::writeHeader(), llvm::sampleprof::SampleProfileWriterText::writeSample(), and writeWithSizeLimitInternal().
|
protected |
Output stream where to emit the profile to.
Definition at line 153 of file SampleProfWriter.h.
Referenced by llvm::sampleprof::SampleProfileWriterExtBinaryBase::addNewSection(), getOutputStream(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::markSectionStart(), llvm::sampleprof::SampleProfileWriterBinary::writeBody(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCSNameIdx(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeCSNameTableSection(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeFuncMetadata(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeFuncOffsetTable(), llvm::sampleprof::SampleProfileWriterBinary::writeMagicIdent(), llvm::sampleprof::SampleProfileWriterBinary::writeNameIdx(), llvm::sampleprof::SampleProfileWriterBinary::writeNameTable(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeNameTable(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeOneSection(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeProfileSymbolListSection(), llvm::sampleprof::SampleProfileWriterText::writeSample(), llvm::sampleprof::SampleProfileWriterBinary::writeSample(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeSample(), llvm::sampleprof::SampleProfileWriterBinary::writeSummary(), and writeWithSizeLimitInternal().
|
protected |
Profile summary.
Definition at line 156 of file SampleProfWriter.h.
Referenced by computeSummary(), and llvm::sampleprof::SampleProfileWriterBinary::writeSummary().