LLVM 19.0.0git
Public Member Functions | Static Public Attributes | List of all members
llvm::PGOCtxProfileWriter Class Referencefinal

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

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 62 of file PGOCtxProfWriter.h.

Constructor & Destructor Documentation

◆ PGOCtxProfileWriter()

llvm::PGOCtxProfileWriter::PGOCtxProfileWriter ( raw_ostream Out,
std::optional< unsigned VersionOverride = std::nullopt 

◆ ~PGOCtxProfileWriter()

llvm::PGOCtxProfileWriter::~PGOCtxProfileWriter ( )

Definition at line 80 of file PGOCtxProfWriter.h.

Member Function Documentation

◆ write()

void PGOCtxProfileWriter::write ( const ctx_profile::ContextNode RootNode)

Definition at line 47 of file PGOCtxProfWriter.cpp.

Member Data Documentation

◆ CodeLen

constexpr unsigned llvm::PGOCtxProfileWriter::CodeLen = 2

Definition at line 85 of file PGOCtxProfWriter.h.

Referenced by PGOCtxProfileWriter().

◆ CurrentVersion

constexpr uint32_t llvm::PGOCtxProfileWriter::CurrentVersion = 1

Definition at line 86 of file PGOCtxProfWriter.h.

Referenced by PGOCtxProfileWriter().

◆ VBREncodingBits

constexpr unsigned llvm::PGOCtxProfileWriter::VBREncodingBits = 6

Definition at line 87 of file PGOCtxProfWriter.h.

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