LLVM 20.0.0git
|
Serialize the remarks to LLVM bitstream. More...
#include "llvm/Remarks/BitstreamRemarkSerializer.h"
Public Member Functions | |
BitstreamRemarkSerializerHelper (BitstreamRemarkContainerType ContainerType) | |
BitstreamRemarkSerializerHelper (const BitstreamRemarkSerializerHelper &)=delete | |
BitstreamRemarkSerializerHelper & | operator= (const BitstreamRemarkSerializerHelper &)=delete |
BitstreamRemarkSerializerHelper (BitstreamRemarkSerializerHelper &&)=delete | |
BitstreamRemarkSerializerHelper & | operator= (BitstreamRemarkSerializerHelper &&)=delete |
void | setupBlockInfo () |
Set up the necessary block info entries according to the container type. | |
void | setupMetaBlockInfo () |
Set up the block info for the metadata block. | |
void | setupMetaRemarkVersion () |
The remark version in the metadata block. | |
void | emitMetaRemarkVersion (uint64_t RemarkVersion) |
void | setupMetaStrTab () |
The strtab in the metadata block. | |
void | emitMetaStrTab (const StringTable &StrTab) |
void | setupMetaExternalFile () |
The external file in the metadata block. | |
void | emitMetaExternalFile (StringRef Filename) |
void | setupRemarkBlockInfo () |
The block info for the remarks block. | |
void | emitMetaBlock (uint64_t ContainerVersion, std::optional< uint64_t > RemarkVersion, std::optional< const StringTable * > StrTab=std::nullopt, std::optional< StringRef > Filename=std::nullopt) |
Emit the metadata for the remarks. | |
void | emitRemarkBlock (const Remark &Remark, StringTable &StrTab) |
Emit a remark block. The string table is required. | |
void | flushToStream (raw_ostream &OS) |
Finalize the writing to OS . | |
StringRef | getBuffer () |
Finalize the writing to a buffer. | |
Public Attributes | |
SmallVector< char, 1024 > | Encoded |
Buffer used for encoding the bitstream before writing it to the final stream. | |
SmallVector< uint64_t, 64 > | R |
Buffer used to construct records and pass to the bitstream writer. | |
BitstreamWriter | Bitstream |
The Bitstream writer. | |
BitstreamRemarkContainerType | ContainerType |
The type of the container we are serializing. | |
uint64_t | RecordMetaContainerInfoAbbrevID = 0 |
Abbrev IDs initialized in the block info block. | |
uint64_t | RecordMetaRemarkVersionAbbrevID = 0 |
uint64_t | RecordMetaStrTabAbbrevID = 0 |
uint64_t | RecordMetaExternalFileAbbrevID = 0 |
uint64_t | RecordRemarkHeaderAbbrevID = 0 |
uint64_t | RecordRemarkDebugLocAbbrevID = 0 |
uint64_t | RecordRemarkHotnessAbbrevID = 0 |
uint64_t | RecordRemarkArgWithDebugLocAbbrevID = 0 |
uint64_t | RecordRemarkArgWithoutDebugLocAbbrevID = 0 |
Serialize the remarks to LLVM bitstream.
This class provides ways to emit remarks in the LLVM bitstream format and its associated metadata.
The separate model: Separate meta: | Container info | String table | External file
Separate remarks: | Container info | Remark version | Remark0 | Remark1 | Remark2 | ...
Definition at line 51 of file BitstreamRemarkSerializer.h.
BitstreamRemarkSerializerHelper::BitstreamRemarkSerializerHelper | ( | BitstreamRemarkContainerType | ContainerType | ) |
Definition at line 21 of file BitstreamRemarkSerializer.cpp.
|
delete |
|
delete |
void BitstreamRemarkSerializerHelper::emitMetaBlock | ( | uint64_t | ContainerVersion, |
std::optional< uint64_t > | RemarkVersion, | ||
std::optional< const StringTable * > | StrTab = std::nullopt , |
||
std::optional< StringRef > | Filename = std::nullopt |
||
) |
Emit the metadata for the remarks.
Definition at line 234 of file BitstreamRemarkSerializer.cpp.
References assert(), Bitstream, llvm::SmallVectorImpl< T >::clear(), ContainerType, emitMetaExternalFile(), emitMetaRemarkVersion(), emitMetaStrTab(), llvm::BitstreamWriter::EmitRecordWithAbbrev(), llvm::BitstreamWriter::EnterSubblock(), llvm::BitstreamWriter::ExitBlock(), llvm::remarks::META_BLOCK_ID, llvm::SmallVectorTemplateBase< T, bool >::push_back(), R, llvm::remarks::RECORD_META_CONTAINER_INFO, RecordMetaContainerInfoAbbrevID, llvm::remarks::SeparateRemarksFile, llvm::remarks::SeparateRemarksMeta, and llvm::remarks::Standalone.
Referenced by llvm::remarks::BitstreamMetaSerializer::emit().
void BitstreamRemarkSerializerHelper::emitMetaExternalFile | ( | StringRef | Filename | ) |
Definition at line 118 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::SmallVectorImpl< T >::clear(), llvm::BitstreamWriter::EmitRecordWithBlob(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), R, llvm::remarks::RECORD_META_EXTERNAL_FILE, and RecordMetaExternalFileAbbrevID.
Referenced by emitMetaBlock().
void BitstreamRemarkSerializerHelper::emitMetaRemarkVersion | ( | uint64_t | RemarkVersion | ) |
Definition at line 75 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::SmallVectorImpl< T >::clear(), llvm::BitstreamWriter::EmitRecordWithAbbrev(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), R, llvm::remarks::RECORD_META_REMARK_VERSION, and RecordMetaRemarkVersionAbbrevID.
Referenced by emitMetaBlock().
void BitstreamRemarkSerializerHelper::emitMetaStrTab | ( | const StringTable & | StrTab | ) |
Definition at line 94 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::SmallVectorImpl< T >::clear(), llvm::BitstreamWriter::EmitRecordWithBlob(), OS, llvm::SmallVectorTemplateBase< T, bool >::push_back(), R, llvm::remarks::RECORD_META_STRTAB, RecordMetaStrTabAbbrevID, and llvm::remarks::StringTable::serialize().
Referenced by emitMetaBlock().
void BitstreamRemarkSerializerHelper::emitRemarkBlock | ( | const Remark & | Remark, |
StringTable & | StrTab | ||
) |
Emit a remark block. The string table is required.
Definition at line 270 of file BitstreamRemarkSerializer.cpp.
References llvm::remarks::StringTable::add(), llvm::remarks::Remark::Args, Bitstream, llvm::SmallVectorImpl< T >::clear(), llvm::BitstreamWriter::EmitRecordWithAbbrev(), llvm::BitstreamWriter::EnterSubblock(), llvm::BitstreamWriter::ExitBlock(), llvm::remarks::Remark::FunctionName, llvm::remarks::Remark::Hotness, llvm::remarks::Argument::Key, llvm::remarks::Argument::Loc, llvm::remarks::Remark::Loc, llvm::remarks::Remark::PassName, llvm::SmallVectorTemplateBase< T, bool >::push_back(), R, llvm::remarks::RECORD_REMARK_ARG_WITH_DEBUGLOC, llvm::remarks::RECORD_REMARK_ARG_WITHOUT_DEBUGLOC, llvm::remarks::RECORD_REMARK_DEBUG_LOC, llvm::remarks::RECORD_REMARK_HEADER, llvm::remarks::RECORD_REMARK_HOTNESS, RecordRemarkArgWithDebugLocAbbrevID, RecordRemarkArgWithoutDebugLocAbbrevID, RecordRemarkDebugLocAbbrevID, RecordRemarkHeaderAbbrevID, RecordRemarkHotnessAbbrevID, llvm::remarks::REMARK_BLOCK_ID, llvm::remarks::Remark::RemarkName, llvm::remarks::Remark::RemarkType, and llvm::remarks::Argument::Val.
Referenced by llvm::remarks::BitstreamRemarkSerializer::emit().
void BitstreamRemarkSerializerHelper::flushToStream | ( | raw_ostream & | OS | ) |
Finalize the writing to OS
.
Definition at line 320 of file BitstreamRemarkSerializer.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorTemplateCommon< T, typename >::data(), Encoded, OS, llvm::SmallVectorBase< Size_T >::size(), and llvm::raw_ostream::write().
Referenced by llvm::remarks::BitstreamMetaSerializer::emit(), and llvm::remarks::BitstreamRemarkSerializer::emit().
StringRef BitstreamRemarkSerializerHelper::getBuffer | ( | ) |
Finalize the writing to a buffer.
The contents of the buffer remain valid for the lifetime of the object. Any call to any other function in this class will invalidate the buffer.
Definition at line 325 of file BitstreamRemarkSerializer.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::data(), Encoded, and llvm::SmallVectorBase< Size_T >::size().
|
delete |
|
delete |
void BitstreamRemarkSerializerHelper::setupBlockInfo | ( | ) |
Set up the necessary block info entries according to the container type.
Definition at line 197 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::CallingConv::C, llvm::remarks::ContainerMagic(), ContainerType, llvm::BitstreamWriter::Emit(), llvm::BitstreamWriter::EnterBlockInfoBlock(), llvm::BitstreamWriter::ExitBlock(), llvm::remarks::SeparateRemarksFile, llvm::remarks::SeparateRemarksMeta, setupMetaBlockInfo(), setupMetaExternalFile(), setupMetaRemarkVersion(), setupMetaStrTab(), setupRemarkBlockInfo(), and llvm::remarks::Standalone.
Referenced by llvm::remarks::BitstreamMetaSerializer::emit().
void BitstreamRemarkSerializerHelper::setupMetaBlockInfo | ( | ) |
Set up the block info for the metadata block.
Definition at line 48 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::BitstreamWriter::EmitBlockInfoAbbrev(), llvm::BitCodeAbbrevOp::Fixed, initBlock(), llvm::remarks::META_BLOCK_ID, llvm::remarks::MetaBlockName, llvm::remarks::MetaContainerInfoName, R, llvm::remarks::RECORD_META_CONTAINER_INFO, RecordMetaContainerInfoAbbrevID, and setRecordName().
Referenced by setupBlockInfo().
void BitstreamRemarkSerializerHelper::setupMetaExternalFile | ( | ) |
The external file in the metadata block.
Definition at line 108 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::BitCodeAbbrevOp::Blob, llvm::BitstreamWriter::EmitBlockInfoAbbrev(), llvm::remarks::META_BLOCK_ID, llvm::remarks::MetaExternalFileName, R, llvm::remarks::RECORD_META_EXTERNAL_FILE, RecordMetaExternalFileAbbrevID, and setRecordName().
Referenced by setupBlockInfo().
void BitstreamRemarkSerializerHelper::setupMetaRemarkVersion | ( | ) |
The remark version in the metadata block.
Definition at line 64 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::BitstreamWriter::EmitBlockInfoAbbrev(), llvm::BitCodeAbbrevOp::Fixed, llvm::remarks::META_BLOCK_ID, llvm::remarks::MetaRemarkVersionName, R, llvm::remarks::RECORD_META_REMARK_VERSION, RecordMetaRemarkVersionAbbrevID, and setRecordName().
Referenced by setupBlockInfo().
void BitstreamRemarkSerializerHelper::setupMetaStrTab | ( | ) |
The strtab in the metadata block.
Definition at line 84 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::BitCodeAbbrevOp::Blob, llvm::BitstreamWriter::EmitBlockInfoAbbrev(), llvm::remarks::META_BLOCK_ID, llvm::remarks::MetaStrTabName, R, llvm::remarks::RECORD_META_STRTAB, RecordMetaStrTabAbbrevID, and setRecordName().
Referenced by setupBlockInfo().
void BitstreamRemarkSerializerHelper::setupRemarkBlockInfo | ( | ) |
The block info for the remarks block.
Definition at line 125 of file BitstreamRemarkSerializer.cpp.
References Bitstream, llvm::BitstreamWriter::EmitBlockInfoAbbrev(), llvm::BitCodeAbbrevOp::Fixed, initBlock(), R, llvm::remarks::RECORD_REMARK_ARG_WITH_DEBUGLOC, llvm::remarks::RECORD_REMARK_ARG_WITHOUT_DEBUGLOC, llvm::remarks::RECORD_REMARK_DEBUG_LOC, llvm::remarks::RECORD_REMARK_HEADER, llvm::remarks::RECORD_REMARK_HOTNESS, RecordRemarkArgWithDebugLocAbbrevID, RecordRemarkArgWithoutDebugLocAbbrevID, RecordRemarkDebugLocAbbrevID, RecordRemarkHeaderAbbrevID, RecordRemarkHotnessAbbrevID, llvm::remarks::REMARK_BLOCK_ID, llvm::remarks::RemarkArgWithDebugLocName, llvm::remarks::RemarkArgWithoutDebugLocName, llvm::remarks::RemarkBlockName, llvm::remarks::RemarkDebugLocName, llvm::remarks::RemarkHeaderName, llvm::remarks::RemarkHotnessName, setRecordName(), and llvm::BitCodeAbbrevOp::VBR.
Referenced by setupBlockInfo().
BitstreamWriter llvm::remarks::BitstreamRemarkSerializerHelper::Bitstream |
The Bitstream writer.
Definition at line 58 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaBlock(), emitMetaExternalFile(), emitMetaRemarkVersion(), emitMetaStrTab(), emitRemarkBlock(), setupBlockInfo(), setupMetaBlockInfo(), setupMetaExternalFile(), setupMetaRemarkVersion(), setupMetaStrTab(), and setupRemarkBlockInfo().
BitstreamRemarkContainerType llvm::remarks::BitstreamRemarkSerializerHelper::ContainerType |
The type of the container we are serializing.
Definition at line 60 of file BitstreamRemarkSerializer.h.
Referenced by llvm::remarks::BitstreamRemarkSerializer::emit(), emitMetaBlock(), llvm::remarks::BitstreamRemarkSerializer::metaSerializer(), and setupBlockInfo().
SmallVector<char, 1024> llvm::remarks::BitstreamRemarkSerializerHelper::Encoded |
Buffer used for encoding the bitstream before writing it to the final stream.
Definition at line 54 of file BitstreamRemarkSerializer.h.
Referenced by flushToStream(), and getBuffer().
SmallVector<uint64_t, 64> llvm::remarks::BitstreamRemarkSerializerHelper::R |
Buffer used to construct records and pass to the bitstream writer.
Definition at line 56 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaBlock(), emitMetaExternalFile(), emitMetaRemarkVersion(), emitMetaStrTab(), emitRemarkBlock(), setupMetaBlockInfo(), setupMetaExternalFile(), setupMetaRemarkVersion(), setupMetaStrTab(), and setupRemarkBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaContainerInfoAbbrevID = 0 |
Abbrev IDs initialized in the block info block.
Note: depending on the container type, some IDs might be uninitialized. Warning: When adding more abbrev IDs, make sure to update the BlockCodeSize (in the call to EnterSubblock).
Definition at line 66 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaBlock(), and setupMetaBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaExternalFileAbbrevID = 0 |
Definition at line 69 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaExternalFile(), and setupMetaExternalFile().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaRemarkVersionAbbrevID = 0 |
Definition at line 67 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaRemarkVersion(), and setupMetaRemarkVersion().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaStrTabAbbrevID = 0 |
Definition at line 68 of file BitstreamRemarkSerializer.h.
Referenced by emitMetaStrTab(), and setupMetaStrTab().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkArgWithDebugLocAbbrevID = 0 |
Definition at line 73 of file BitstreamRemarkSerializer.h.
Referenced by emitRemarkBlock(), and setupRemarkBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkArgWithoutDebugLocAbbrevID = 0 |
Definition at line 74 of file BitstreamRemarkSerializer.h.
Referenced by emitRemarkBlock(), and setupRemarkBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkDebugLocAbbrevID = 0 |
Definition at line 71 of file BitstreamRemarkSerializer.h.
Referenced by emitRemarkBlock(), and setupRemarkBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkHeaderAbbrevID = 0 |
Definition at line 70 of file BitstreamRemarkSerializer.h.
Referenced by emitRemarkBlock(), and setupRemarkBlockInfo().
uint64_t llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkHotnessAbbrevID = 0 |
Definition at line 72 of file BitstreamRemarkSerializer.h.
Referenced by emitRemarkBlock(), and setupRemarkBlockInfo().