Writer that serializes contextual PGO profiles to a bitstream.

Synopsis

Declared in <llvm/ProfileData/PGOCtxProfWriter.h>

class PGOCtxProfileWriter final
    : public ctx_profile::ProfileWriter

Description

Write one or more ContextNodes to the provided raw_ostream. 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)

Base Classes

Name

Description

ctx_profile::ProfileWriter

Callback interface passed to __llvm_ctx_profile_fetch.

Member Functions

Name

Description

PGOCtxProfileWriter [constructor]

Construct a writer that emits into Out.

~PGOCtxProfileWriter [destructor] [virtual]

Destroy the writer and exit the open metadata block.

endContextSection [virtual]

Finish writing the contextual profile section.

endFlatSection [virtual]

Finish writing the flat profile section.

startContextSection [virtual]

Begin writing the contextual profile section.

startFlatSection [virtual]

Begin writing the flat profile section.

writeContextual [virtual]

Write one contextual profile root and optional unhandled contexts.

writeFlat [virtual]

Write one flat profile buffer for Guid.

Static Data Members

Name

Description

CodeLen

Bit width of abbreviated record codes written by this format.

ContainerMagic

Four‐byte magic prefix identifying a contextual profile container.

CurrentVersion

Default contextual profile format version emitted by the writer.

VBREncodingBits

VBR chunk width used when encoding record operands.

Created with MrDocs