LLVM 20.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) | |
~PGOCtxProfileWriter () | |
void | write (const ctx_profile::ContextNode &) |
Static Public Attributes | |
static constexpr unsigned | CodeLen = 2 |
static constexpr uint32_t | CurrentVersion = 1 |
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 63 of file PGOCtxProfWriter.h.
PGOCtxProfileWriter::PGOCtxProfileWriter | ( | raw_ostream & | Out, |
std::optional< unsigned > | VersionOverride = std::nullopt |
||
) |
Definition at line 19 of file PGOCtxProfWriter.cpp.
References llvm::append_range(), llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, llvm::bitc::BLOCKINFO_CODE_SETBID, llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, llvm::CalleeIndex, CodeLen, ContainerMagic, llvm::ContextNodeBlockID, llvm::Counters, CurrentVersion, llvm::StringRef::data(), llvm::Data, llvm::BitstreamWriter::EmitRecord(), llvm::BitstreamWriter::EnterBlockInfoBlock(), llvm::BitstreamWriter::EnterSubblock(), llvm::BitstreamWriter::ExitBlock(), llvm::Guid, Name, llvm::ProfileMetadataBlockID, llvm::StringRef::size(), llvm::Version, and llvm::raw_ostream::write().
|
inline |
Definition at line 73 of file PGOCtxProfWriter.h.
void PGOCtxProfileWriter::write | ( | const ctx_profile::ContextNode & | RootNode | ) |
Definition at line 81 of file PGOCtxProfWriter.cpp.
|
staticconstexpr |
Definition at line 78 of file PGOCtxProfWriter.h.
Referenced by PGOCtxProfileWriter().
|
staticconstexpr |
Definition at line 81 of file PGOCtxProfWriter.h.
Referenced by PGOCtxProfileWriter().
|
staticconstexpr |
Definition at line 79 of file PGOCtxProfWriter.h.
Referenced by PGOCtxProfileWriter().
|
staticconstexpr |
Definition at line 80 of file PGOCtxProfWriter.h.