|
LLVM 22.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 90 of file SampleProfWriter.h.
|
virtualdefault |
|
inlineprotected |
Definition at line 135 of file SampleProfWriter.h.
References llvm::move(), and OutputStream.
Referenced by llvm::sampleprof::SampleProfileWriterBinary::SampleProfileWriterBinary(), and llvm::sampleprof::SampleProfileWriterText::SampleProfileWriterText().
|
protected |
Compute summary for this profile.
Definition at line 988 of file SampleProfWriter.cpp.
References 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 960 of file SampleProfWriter.cpp.
References Format, 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 939 of file SampleProfWriter.cpp.
References create(), Format, llvm::sys::fs::OF_None, llvm::sys::fs::OF_TextWithCRLF, llvm::sampleprof::SPF_Binary, and llvm::sampleprof::SPF_Ext_Binary.
Referenced by create(), llvm::sampleprof::SampleProfileWriterBinary::SampleProfileWriter::create, and llvm::sampleprof::SampleProfileWriterText::SampleProfileWriter::create.
|
inline |
Definition at line 115 of file SampleProfWriter.h.
References OutputStream.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 131 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 128 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 129 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase, and llvm::sampleprof::SampleProfileWriterText.
Definition at line 132 of file SampleProfWriter.h.
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 130 of file SampleProfWriter.h.
|
virtual |
Write all the sample profiles in the given map of samples.
Reimplemented in llvm::sampleprof::SampleProfileWriterExtBinaryBase.
Definition at line 156 of file SampleProfWriter.cpp.
References llvm::success, writeFuncProfiles(), and writeHeader().
Referenced by writeWithSizeLimitInternal().
|
protectedvirtual |
Definition at line 146 of file SampleProfWriter.cpp.
References I, llvm::sampleprof::sortFuncProfiles(), llvm::success, and writeSample().
Referenced by write(), writeHeader(), and llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeOneSection().
|
protectedpure virtual |
Write a file header for the profile file.
Implemented in llvm::sampleprof::SampleProfileWriterBinary, and llvm::sampleprof::SampleProfileWriterText.
References writeFuncProfiles(), and writeWithSizeLimitInternal().
Referenced by write().
|
pure virtual |
Write sample profiles in S.
Implemented in llvm::sampleprof::SampleProfileWriterBinary, llvm::sampleprof::SampleProfileWriterExtBinaryBase, and llvm::sampleprof::SampleProfileWriterText.
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 109 of file SampleProfWriter.h.
References writeWithSizeLimitInternal().
|
protected |
Definition at line 95 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::SmallVectorTemplateCommon< T, typename >::size(), llvm::sampleprof::SPF_Text, llvm::success, llvm::too_large, and write().
Referenced by writeHeader(), and writeWithSizeLimit().
|
protected |
Profile format.
Definition at line 163 of file SampleProfWriter.h.
Referenced by create(), create(), llvm::sampleprof::SampleProfileWriterBinary::SampleProfileWriter::create, llvm::sampleprof::SampleProfileWriterText::SampleProfileWriter::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 151 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 154 of file SampleProfWriter.h.
Referenced by llvm::sampleprof::SampleProfileWriterExtBinaryBase::addNewSection(), getOutputStream(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::markSectionStart(), SampleProfileWriter(), 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::SampleProfileWriterBinary::writeSample(), llvm::sampleprof::SampleProfileWriterExtBinaryBase::writeSample(), llvm::sampleprof::SampleProfileWriterText::writeSample(), llvm::sampleprof::SampleProfileWriterBinary::writeSummary(), and writeWithSizeLimitInternal().
|
protected |
Profile summary.
Definition at line 157 of file SampleProfWriter.h.
Referenced by computeSummary(), and llvm::sampleprof::SampleProfileWriterBinary::writeSummary().