LLVM 22.0.0git
llvm::PGOCtxProfileWriter Class Referencefinal

Write one or more ContextNodes to the provided raw_fd_stream. More...

#include "llvm/ProfileData/PGOCtxProfWriter.h"

Inheritance diagram for llvm::PGOCtxProfileWriter:
[legend]

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"

Detailed Description

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.

Constructor & Destructor Documentation

◆ PGOCtxProfileWriter()

◆ ~PGOCtxProfileWriter()

llvm::PGOCtxProfileWriter::~PGOCtxProfileWriter ( )
inline

Definition at line 95 of file PGOCtxProfWriter.h.

Member Function Documentation

◆ endContextSection()

void PGOCtxProfileWriter::endContextSection ( )
overridevirtual

Implements llvm::ctx_profile::ProfileWriter.

Definition at line 134 of file PGOCtxProfWriter.cpp.

Referenced by llvm::createCtxProfFromYAML().

◆ endFlatSection()

void PGOCtxProfileWriter::endFlatSection ( )
overridevirtual

Implements llvm::ctx_profile::ProfileWriter.

Definition at line 135 of file PGOCtxProfWriter.cpp.

Referenced by llvm::createCtxProfFromYAML().

◆ startContextSection()

void PGOCtxProfileWriter::startContextSection ( )
overridevirtual

◆ startFlatSection()

void PGOCtxProfileWriter::startFlatSection ( )
overridevirtual

◆ writeContextual()

◆ writeFlat()

void PGOCtxProfileWriter::writeFlat ( ctx_profile::GUID Guid,
const uint64_t * Buffer,
size_t BufferSize )
overridevirtual

Member Data Documentation

◆ CodeLen

unsigned llvm::PGOCtxProfileWriter::CodeLen = 2
staticconstexpr

◆ ContainerMagic

StringRef llvm::PGOCtxProfileWriter::ContainerMagic = "CTXP"
staticconstexpr

Definition at line 112 of file PGOCtxProfWriter.h.

Referenced by PGOCtxProfileWriter().

◆ CurrentVersion

uint32_t llvm::PGOCtxProfileWriter::CurrentVersion = 4
staticconstexpr

Definition at line 110 of file PGOCtxProfWriter.h.

◆ VBREncodingBits

unsigned llvm::PGOCtxProfileWriter::VBREncodingBits = 6
staticconstexpr

Definition at line 111 of file PGOCtxProfWriter.h.


The documentation for this class was generated from the following files: