LLVM 22.0.0git
|
Write one or more ContextNodes to the provided raw_fd_stream. More...
#include "llvm/ProfileData/PGOCtxProfWriter.h"
Public Member Functions | |
PGOCtxProfileWriter (raw_ostream &Out, std::optional< unsigned > VersionOverride=std::nullopt, bool IncludeEmpty=false) | |
~PGOCtxProfileWriter () | |
void | startContextSection () override |
void | writeContextual (const ctx_profile::ContextNode &RootNode, const ctx_profile::ContextNode *Unhandled, uint64_t TotalRootEntryCount) override |
void | endContextSection () override |
void | startFlatSection () override |
void | writeFlat (ctx_profile::GUID Guid, const uint64_t *Buffer, size_t BufferSize) override |
void | endFlatSection () override |
Public Member Functions inherited from llvm::ctx_profile::ProfileWriter | |
virtual | ~ProfileWriter ()=default |
Static Public Attributes | |
static constexpr unsigned | CodeLen = 2 |
static constexpr uint32_t | CurrentVersion = 4 |
static constexpr unsigned | VBREncodingBits = 6 |
static constexpr StringRef | ContainerMagic = "CTXP" |
Write one or more ContextNodes to the provided raw_fd_stream.
The caller must destroy the PGOCtxProfileWriter object before closing the stream. The design allows serializing a bunch of contexts embedded in some other file. The overall format is:
[... other data written to the stream...] SubBlock(ProfileMetadataBlockID) Version SubBlock(ContextNodeBlockID) [RECORDS] SubBlock(ContextNodeBlockID) [RECORDS] [... more SubBlocks] EndBlock EndBlock
The "RECORDS" are bitsream records. The IDs are in CtxProfileCodes (except) for Version, which is just for metadata). All contexts will have Guid and Counters, and all but the roots have CalleeIndex. The order in which the records appear does not matter, but they must precede any subcontexts, because that helps keep the reader code simpler.
Subblock containment captures the context->subcontext relationship. The "next()" relationship in the raw profile, between call targets of indirect calls, are just modeled as peer subblocks where the callee index is the same.
Versioning: the writer may produce additional records not known by the reader. The version number indicates a more structural change. The current version, in particular, is set up to expect optional extensions like value profiling - which would appear as additional records. For example, value profiling would produce a new record with a new record ID, containing the profiled values (much like the counters)
Definition at line 78 of file PGOCtxProfWriter.h.
PGOCtxProfileWriter::PGOCtxProfileWriter | ( | raw_ostream & | Out, |
std::optional< unsigned > | VersionOverride = std::nullopt, | ||
bool | IncludeEmpty = false ) |
Definition at line 29 of file PGOCtxProfWriter.cpp.
References llvm::CallsiteIndex, ContainerMagic, llvm::ContextNodeBlockID, llvm::ContextRootBlockID, llvm::ContextsSectionBlockID, llvm::Counters, llvm::Data, llvm::FlatProfileBlockID, llvm::FlatProfilesSectionBlockID, llvm::Guid, IncludeEmptyOpt, llvm::ProfileMetadataBlockID, llvm::TotalRootEntryCount, llvm::UnhandledBlockID, and llvm::raw_ostream::write().
|
inline |
Definition at line 95 of file PGOCtxProfWriter.h.
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 134 of file PGOCtxProfWriter.cpp.
Referenced by llvm::createCtxProfFromYAML().
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 135 of file PGOCtxProfWriter.cpp.
Referenced by llvm::createCtxProfFromYAML().
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 125 of file PGOCtxProfWriter.cpp.
References CodeLen, and llvm::ContextsSectionBlockID.
Referenced by llvm::createCtxProfFromYAML().
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 129 of file PGOCtxProfWriter.cpp.
References CodeLen, and llvm::FlatProfilesSectionBlockID.
Referenced by llvm::createCtxProfFromYAML().
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 137 of file PGOCtxProfWriter.cpp.
References CodeLen, llvm::ContextRootBlockID, llvm::ctx_profile::ContextNode::counters(), llvm::ctx_profile::ContextNode::counters_size(), llvm::ctx_profile::ContextNode::entrycount(), llvm::ctx_profile::ContextNode::guid(), P, llvm::TotalRootEntryCount, llvm::UnhandledBlockID, and writeFlat().
Referenced by llvm::createCtxProfFromYAML().
|
overridevirtual |
Implements llvm::ctx_profile::ProfileWriter.
Definition at line 157 of file PGOCtxProfWriter.cpp.
References CodeLen, llvm::FlatProfileBlockID, llvm::Guid, and Size.
Referenced by llvm::createCtxProfFromYAML(), and writeContextual().
|
staticconstexpr |
Definition at line 109 of file PGOCtxProfWriter.h.
Referenced by startContextSection(), startFlatSection(), writeContextual(), and writeFlat().
|
staticconstexpr |
Definition at line 112 of file PGOCtxProfWriter.h.
Referenced by PGOCtxProfileWriter().
|
staticconstexpr |
Definition at line 110 of file PGOCtxProfWriter.h.
|
staticconstexpr |
Definition at line 111 of file PGOCtxProfWriter.h.