Go to the documentation of this file.
12 #ifndef LLVM_PROFILEDATA_SAMPLEPROFWRITER_H
13 #define LLVM_PROFILEDATA_SAMPLEPROFWRITER_H
24 #include <system_error>
27 namespace sampleprof {
131 virtual std::error_code
138 std::set<StringRef> &V);
156 const std::array<SmallVector<SecHdrTableEntry, 8>,
NumOfLayout>
221 assert(Entry.Flags == 0 &&
222 "resetSecLayout has to be called before any flag setting");
233 template <
class SecFlagType>
236 if (Entry.Type ==
Type)
240 template <
class SecFlagType>
262 virtual std::error_code
289 void allocSecHdrTable();
290 std::error_code writeSecHdrTable();
291 virtual std::error_code
293 std::error_code compressAndOutput();
303 std::unique_ptr<raw_ostream> LocalBufStream;
313 std::vector<SecHdrTableEntry> SecHdrTable;
337 virtual std::error_code
340 virtual std::error_code writeCustomSection(
SecType Type)
override {
346 "Unsupported layout");
395 virtual std::error_code
403 #endif // LLVM_PROFILEDATA_SAMPLEPROFWRITER_H
SampleProfileWriterText(std::unique_ptr< raw_ostream > &OS)
std::unique_ptr< raw_ostream > OutputStream
Output stream where to emit the profile to.
void addSectionFlag(uint32_t SectionIdx, SecFlagType Flag)
MapVector< StringRef, uint32_t > NameTable
Sample-based profile writer (text format).
static ErrorOr< std::unique_ptr< SampleProfileWriter > > create(StringRef Filename, SampleProfileFormat Format)
Profile writer factory.
This is an optimization pass for GlobalISel generic memory operations.
void stablizeNameTable(MapVector< StringRef, uint32_t > &NameTable, std::set< StringRef > &V)
virtual std::error_code writeNameTable() override
SampleProfileFormat Format
Profile format.
virtual void setPartialProfile() override
std::error_code writeBody(const FunctionSamples &S)
std::error_code writeFuncOffsetTable()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
virtual void setToCompressAllSections()
std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash > SampleProfileMap
The instances of the Type class are immutable: once they are created, they are never changed.
void addName(StringRef FName)
void computeSummary(const SampleProfileMap &ProfileMap)
Compute summary for this profile.
static void addSecFlag(SecHdrTableEntry &Entry, SecFlagType Flag)
std::error_code writeFuncOffsetTable()
This class implements a map that also provides access to all stored values in a deterministic order.
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap) override
Write a file header for the profile file.
std::error_code writeNameTableSection(const SampleProfileMap &ProfileMap)
virtual std::error_code writeFuncProfiles(const SampleProfileMap &ProfileMap)
virtual void setToCompressAllSections() override
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
virtual std::error_code writeCustomSection(SecType Type)=0
std::unique_ptr< ProfileSummary > Summary
Profile summary.
virtual std::error_code writeSections(const SampleProfileMap &ProfileMap)=0
void addNames(const FunctionSamples &S)
virtual std::error_code write(const SampleProfileMap &ProfileMap)
Write all the sample profiles in the given map of samples.
@ SecFlagPartial
SecFlagPartial means the profile is for common/shared code.
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap) override
Write a file header for the profile file.
virtual void addContext(const SampleContext &Context) override
virtual std::error_code writeNameTable()
virtual std::error_code writeSample(const FunctionSamples &S)=0
Write sample profiles in S.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
virtual void setProfileSymbolList(ProfileSymbolList *PSL) override
This class implements an extremely fast bulk output stream that can only output to a stream.
SmallVector< SecHdrTableEntry, 8 > SectionHdrLayout
uint64_t TableOffset
The offset of the slot to be filled with the offset of FuncOffsetTable towards profile start.
virtual std::error_code write(const SampleProfileMap &ProfileMap) override
Write all the sample profiles in the given map of samples.
virtual void setPartialProfile()
virtual ~SampleProfileWriter()=default
virtual std::error_code writeNameTable() override
SampleProfileWriterBinary(std::unique_ptr< raw_ostream > &OS)
MapVector< StringRef, uint64_t > FuncOffsetTable
The table mapping from function name to the offset of its FunctionSample towards profile start.
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 sectio...
virtual MapVector< StringRef, uint32_t > & getNameTable()
ProfileSymbolList records the list of function symbols shown up in the binary used to generate the pr...
virtual std::error_code write(const SampleProfileMap &ProfileMap) override
Write all the sample profiles in the given map of samples.
std::error_code writeHeader(const SampleProfileMap &ProfileMap) override
Write a file header for the profile file.
Representation of the samples collected for a function.
virtual void resetSecLayout(SectionLayout SL)
std::error_code writeCSNameIdx(const SampleContext &Context)
SampleProfileWriter(std::unique_ptr< raw_ostream > &OS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void addContext(const SampleContext &Context)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void addSectionFlag(SecType Type, SecFlagType Flag)
std::error_code writeSample(const FunctionSamples &S) override
Write samples to a text file.
std::error_code writeNameIdx(StringRef FName)
virtual void setUseMD5() override
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 Se...
StringRef - Represent a constant reference to a string, i.e.
std::error_code writeFuncMetadata(const SampleProfileMap &Profiles)
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
virtual std::error_code writeHeader(const SampleProfileMap &ProfileMap)=0
Write a file header for the profile file.
virtual std::error_code writeOneSection(SecType Type, uint32_t LayoutIdx, const SampleProfileMap &ProfileMap)
std::error_code writeSummary()
void setToCompressSection(SecType Type)
virtual void setProfileSymbolList(ProfileSymbolList *PSL)
virtual void verifySecLayout(SectionLayout SL)=0
uint64_t SecLBRProfileStart
std::error_code writeCSNameTableSection()
std::error_code writeProfileSymbolListSection()
virtual std::error_code writeContextIdx(const SampleContext &Context)
virtual void resetSecLayout(SectionLayout SL) override
virtual std::error_code writeContextIdx(const SampleContext &Context) override
Sample-based profile writer (binary format).
virtual std::error_code writeSample(const FunctionSamples &S) override
Write samples of a top-level function to a binary file.
const std::array< SmallVector< SecHdrTableEntry, 8 >, NumOfLayout > ExtBinaryHdrLayoutTable
Represents either an error or a value T.
virtual std::error_code writeMagicIdent(SampleProfileFormat Format)
SampleProfileWriterExtBinary(std::unique_ptr< raw_ostream > &OS)
raw_ostream & getOutputStream()
Sample-based profile writer. Base class.