LLVM  17.0.0git
BitstreamRemarkSerializer.cpp
Go to the documentation of this file.
1 //===- BitstreamRemarkSerializer.cpp --------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the implementation of the LLVM bitstream remark serializer
10 // using LLVM's bitstream writer.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/Remarks/Remark.h"
16 #include <optional>
17 
18 using namespace llvm;
19 using namespace llvm::remarks;
20 
22  BitstreamRemarkContainerType ContainerType)
23  : Bitstream(Encoded), ContainerType(ContainerType) {}
24 
26  append_range(R, Str);
27 }
28 
29 static void setRecordName(unsigned RecordID, BitstreamWriter &Bitstream,
31  R.clear();
32  R.push_back(RecordID);
33  push(R, Str);
35 }
36 
37 static void initBlock(unsigned BlockID, BitstreamWriter &Bitstream,
39  R.clear();
40  R.push_back(BlockID);
42 
43  R.clear();
44  push(R, Str);
46 }
47 
49  // Setup the metadata block.
51 
52  // The container information.
55 
56  auto Abbrev = std::make_shared<BitCodeAbbrev>();
58  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Version.
59  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Type.
62 }
63 
67 
68  auto Abbrev = std::make_shared<BitCodeAbbrev>();
70  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Version.
73 }
74 
76  uint64_t RemarkVersion) {
77  // The remark version is emitted only if we emit remarks.
78  R.clear();
79  R.push_back(RECORD_META_REMARK_VERSION);
80  R.push_back(RemarkVersion);
82 }
83 
86 
87  auto Abbrev = std::make_shared<BitCodeAbbrev>();
88  Abbrev->Add(BitCodeAbbrevOp(RECORD_META_STRTAB));
89  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Raw table.
92 }
93 
95  const StringTable &StrTab) {
96  // The string table is not emitted if we emit remarks separately.
97  R.clear();
98  R.push_back(RECORD_META_STRTAB);
99 
100  // Serialize to a blob.
101  std::string Buf;
102  raw_string_ostream OS(Buf);
103  StrTab.serialize(OS);
104  StringRef Blob = OS.str();
106 }
107 
110 
111  auto Abbrev = std::make_shared<BitCodeAbbrev>();
113  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Filename.
116 }
117 
119  // The external file is emitted only if we emit the separate metadata.
120  R.clear();
121  R.push_back(RECORD_META_EXTERNAL_FILE);
123 }
124 
126  // Setup the remark block.
128 
129  // The header of a remark.
130  {
132 
133  auto Abbrev = std::make_shared<BitCodeAbbrev>();
135  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Type
136  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Remark Name
137  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Pass name
138  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Function name
141  }
142 
143  // The location of a remark.
144  {
146 
147  auto Abbrev = std::make_shared<BitCodeAbbrev>();
149  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // File
150  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Line
151  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Column
154  }
155 
156  // The hotness of a remark.
157  {
159 
160  auto Abbrev = std::make_shared<BitCodeAbbrev>();
162  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Hotness
165  }
166 
167  // An argument entry with a debug location attached.
168  {
171 
172  auto Abbrev = std::make_shared<BitCodeAbbrev>();
174  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // Key
175  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // Value
176  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // File
177  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Line
178  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Column
181  }
182 
183  // An argument entry with no debug location attached.
184  {
187 
188  auto Abbrev = std::make_shared<BitCodeAbbrev>();
190  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // Key
191  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 7)); // Value
194  }
195 }
196 
198  // Emit magic number.
199  for (const char C : ContainerMagic)
200  Bitstream.Emit(static_cast<unsigned>(C), 8);
201 
203 
204  // Setup the main metadata. Depending on the container type, we'll setup the
205  // required records next.
207 
208  switch (ContainerType) {
210  // Needs a string table that the separate remark file is using.
211  setupMetaStrTab();
212  // Needs to know where the external remarks file is.
214  break;
216  // Contains remarks: emit the version.
218  // Contains remarks: emit the remark abbrevs.
220  break;
222  // Contains remarks: emit the version.
224  // Needs a string table.
225  setupMetaStrTab();
226  // Contains remarks: emit the remark abbrevs.
228  break;
229  }
230 
232 }
233 
235  uint64_t ContainerVersion, std::optional<uint64_t> RemarkVersion,
236  std::optional<const StringTable *> StrTab,
237  std::optional<StringRef> Filename) {
238  // Emit the meta block
240 
241  // The container version and type.
242  R.clear();
243  R.push_back(RECORD_META_CONTAINER_INFO);
244  R.push_back(ContainerVersion);
245  R.push_back(static_cast<uint64_t>(ContainerType));
247 
248  switch (ContainerType) {
250  assert(StrTab != std::nullopt && *StrTab != nullptr);
251  emitMetaStrTab(**StrTab);
252  assert(Filename != std::nullopt);
253  emitMetaExternalFile(*Filename);
254  break;
256  assert(RemarkVersion != std::nullopt);
257  emitMetaRemarkVersion(*RemarkVersion);
258  break;
260  assert(RemarkVersion != std::nullopt);
261  emitMetaRemarkVersion(*RemarkVersion);
262  assert(StrTab != std::nullopt && *StrTab != nullptr);
263  emitMetaStrTab(**StrTab);
264  break;
265  }
266 
268 }
269 
271  StringTable &StrTab) {
273 
274  R.clear();
275  R.push_back(RECORD_REMARK_HEADER);
276  R.push_back(static_cast<uint64_t>(Remark.RemarkType));
277  R.push_back(StrTab.add(Remark.RemarkName).first);
278  R.push_back(StrTab.add(Remark.PassName).first);
279  R.push_back(StrTab.add(Remark.FunctionName).first);
281 
282  if (const std::optional<RemarkLocation> &Loc = Remark.Loc) {
283  R.clear();
284  R.push_back(RECORD_REMARK_DEBUG_LOC);
285  R.push_back(StrTab.add(Loc->SourceFilePath).first);
286  R.push_back(Loc->SourceLine);
287  R.push_back(Loc->SourceColumn);
289  }
290 
291  if (std::optional<uint64_t> Hotness = Remark.Hotness) {
292  R.clear();
293  R.push_back(RECORD_REMARK_HOTNESS);
294  R.push_back(*Hotness);
296  }
297 
298  for (const Argument &Arg : Remark.Args) {
299  R.clear();
300  unsigned Key = StrTab.add(Arg.Key).first;
301  unsigned Val = StrTab.add(Arg.Val).first;
302  bool HasDebugLoc = Arg.Loc != std::nullopt;
303  R.push_back(HasDebugLoc ? RECORD_REMARK_ARG_WITH_DEBUGLOC
305  R.push_back(Key);
306  R.push_back(Val);
307  if (HasDebugLoc) {
308  R.push_back(StrTab.add(Arg.Loc->SourceFilePath).first);
309  R.push_back(Arg.Loc->SourceLine);
310  R.push_back(Arg.Loc->SourceColumn);
311  }
312  Bitstream.EmitRecordWithAbbrev(HasDebugLoc
315  R);
316  }
318 }
319 
321  OS.write(Encoded.data(), Encoded.size());
322  Encoded.clear();
323 }
324 
326  return StringRef(Encoded.data(), Encoded.size());
327 }
328 
334  "For SerializerMode::Standalone, a pre-filled string table needs to "
335  "be provided.");
336  // We always use a string table with bitstream.
337  StrTab.emplace();
338 }
339 
342  StringTable StrTabIn)
344  Helper(Mode == SerializerMode::Separate
347  StrTab = std::move(StrTabIn);
348 }
349 
351  if (!DidSetUp) {
352  // Emit the metadata that is embedded in the remark file.
353  // If we're in standalone mode, serialize the string table as well.
354  bool IsStandalone =
357  OS, Helper,
358  IsStandalone ? &*StrTab
359  : std::optional<const StringTable *>(std::nullopt));
361  DidSetUp = true;
362  }
363 
364  assert(DidSetUp &&
365  "The Block info block and the meta block were not emitted yet.");
367 
369 }
370 
371 std::unique_ptr<MetaSerializer> BitstreamRemarkSerializer::metaSerializer(
372  raw_ostream &OS, std::optional<StringRef> ExternalFilename) {
375  bool IsStandalone =
377  return std::make_unique<BitstreamMetaSerializer>(
378  OS,
381  &*StrTab, ExternalFilename);
382 }
383 
389 }
llvm::remarks::SerializerMode
SerializerMode
Definition: RemarkSerializer.h:28
llvm::remarks::BitstreamMetaSerializer::Helper
BitstreamRemarkSerializerHelper * Helper
The actual helper, that can point to TmpHelper or to an external helper object.
Definition: BitstreamRemarkSerializer.h:168
llvm::remarks::Remark::Args
SmallVector< Argument, 5 > Args
Arguments collected via the streaming interface.
Definition: Remark.h:90
llvm::remarks::RemarkArgWithoutDebugLocName
constexpr StringRef RemarkArgWithoutDebugLocName
Definition: BitstreamRemarkContainer.h:101
llvm::remarks::BitstreamRemarkSerializer::DidSetUp
bool DidSetUp
The file should contain: 1) The block info block that describes how to read the blocks.
Definition: BitstreamRemarkSerializer.h:133
llvm::BitstreamWriter::EmitRecordWithBlob
void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob)
EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at...
Definition: BitstreamWriter.h:514
llvm::remarks::BitstreamRemarkSerializerHelper::Bitstream
BitstreamWriter Bitstream
The Bitstream writer.
Definition: BitstreamRemarkSerializer.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::remarks::Format::Bitstream
@ Bitstream
llvm::remarks::MetaBlockName
constexpr StringRef MetaBlockName
Definition: BitstreamRemarkContainer.h:70
llvm::remarks::StringTable
The string table used for serializing remarks.
Definition: RemarkStringTable.h:36
llvm::remarks::BitstreamMetaSerializer::StrTab
std::optional< const StringTable * > StrTab
Definition: BitstreamRemarkSerializer.h:170
llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaExternalFileAbbrevID
uint64_t RecordMetaExternalFileAbbrevID
Definition: BitstreamRemarkSerializer.h:69
llvm::remarks::BitstreamRemarkSerializerHelper::R
SmallVector< uint64_t, 64 > R
Buffer used to construct records and pass to the bitstream writer.
Definition: BitstreamRemarkSerializer.h:56
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:642
llvm::remarks::RECORD_META_CONTAINER_INFO
@ RECORD_META_CONTAINER_INFO
Definition: BitstreamRemarkContainer.h:77
llvm::BitCodeAbbrevOp::Fixed
@ Fixed
Definition: BitCodes.h:39
llvm::remarks::SerializerMode::Separate
@ Separate
llvm::remarks::RECORD_REMARK_DEBUG_LOC
@ RECORD_REMARK_DEBUG_LOC
Definition: BitstreamRemarkContainer.h:83
llvm::BitstreamWriter::Emit
void Emit(uint32_t Val, unsigned NumBits)
Definition: BitstreamWriter.h:197
push
static void push(SmallVectorImpl< uint64_t > &R, StringRef Str)
Definition: BitstreamRemarkSerializer.cpp:25
llvm::remarks::Remark::PassName
StringRef PassName
Name of the pass that triggers the emission of this remark.
Definition: Remark.h:72
llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaRemarkVersionAbbrevID
uint64_t RecordMetaRemarkVersionAbbrevID
Definition: BitstreamRemarkSerializer.h:67
llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkHeaderAbbrevID
uint64_t RecordRemarkHeaderAbbrevID
Definition: BitstreamRemarkSerializer.h:70
llvm::remarks::RemarkArgWithDebugLocName
constexpr StringRef RemarkArgWithDebugLocName
Definition: BitstreamRemarkContainer.h:99
llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaRemarkVersion
void setupMetaRemarkVersion()
The remark version in the metadata block.
Definition: BitstreamRemarkSerializer.cpp:64
llvm::remarks::RemarkSerializer::OS
raw_ostream & OS
The open raw_ostream that the remark diagnostics are emitted to.
Definition: RemarkSerializer.h:46
llvm::remarks::BitstreamRemarkSerializerHelper::setupRemarkBlockInfo
void setupRemarkBlockInfo()
The block info for the remarks block.
Definition: BitstreamRemarkSerializer.cpp:125
llvm::remarks::RemarkHeaderName
constexpr StringRef RemarkHeaderName
Definition: BitstreamRemarkContainer.h:96
llvm::remarks::BitstreamRemarkSerializer::Helper
BitstreamRemarkSerializerHelper Helper
The helper to emit bitstream.
Definition: BitstreamRemarkSerializer.h:135
llvm::remarks::StringTable::serialize
void serialize(raw_ostream &OS) const
Serialize the string table to a stream.
Definition: RemarkStringTable.cpp:56
llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaExternalFile
void emitMetaExternalFile(StringRef Filename)
Definition: BitstreamRemarkSerializer.cpp:118
llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaContainerInfoAbbrevID
uint64_t RecordMetaContainerInfoAbbrevID
Abbrev IDs initialized in the block info block.
Definition: BitstreamRemarkSerializer.h:66
llvm::remarks::RemarkSerializer::Mode
SerializerMode Mode
The serialization mode.
Definition: RemarkSerializer.h:48
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
llvm::remarks::BitstreamRemarkSerializerHelper::emitRemarkBlock
void emitRemarkBlock(const Remark &Remark, StringTable &StrTab)
Emit a remark block. The string table is required.
Definition: BitstreamRemarkSerializer.cpp:270
llvm::remarks::BitstreamRemarkSerializerHelper::BitstreamRemarkSerializerHelper
BitstreamRemarkSerializerHelper(BitstreamRemarkContainerType ContainerType)
Definition: BitstreamRemarkSerializer.cpp:21
llvm::remarks::RECORD_REMARK_ARG_WITH_DEBUGLOC
@ RECORD_REMARK_ARG_WITH_DEBUGLOC
Definition: BitstreamRemarkContainer.h:85
llvm::BitstreamWriter::EnterSubblock
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
Definition: BitstreamWriter.h:276
llvm::remarks::Remark::FunctionName
StringRef FunctionName
Mangled name of the function that triggers the emssion of this remark.
Definition: Remark.h:80
llvm::remarks::BitstreamRemarkSerializerHelper::RecordMetaStrTabAbbrevID
uint64_t RecordMetaStrTabAbbrevID
Definition: BitstreamRemarkSerializer.h:68
initBlock
static void initBlock(unsigned BlockID, BitstreamWriter &Bitstream, SmallVectorImpl< uint64_t > &R, StringRef Str)
Definition: BitstreamRemarkSerializer.cpp:37
llvm::remarks::Remark::Loc
std::optional< RemarkLocation > Loc
The location in the source file of the remark.
Definition: Remark.h:83
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME
@ BLOCKINFO_CODE_SETRECORDNAME
Definition: BitCodeEnums.h:83
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
Remark.h
llvm::BitstreamWriter
Definition: BitstreamWriter.h:30
llvm::remarks::RECORD_META_EXTERNAL_FILE
@ RECORD_META_EXTERNAL_FILE
Definition: BitstreamRemarkContainer.h:80
llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaRemarkVersion
void emitMetaRemarkVersion(uint64_t RemarkVersion)
Definition: BitstreamRemarkSerializer.cpp:75
llvm::raw_ostream::write
raw_ostream & write(unsigned char C)
Definition: raw_ostream.cpp:218
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::remarks::MetaRemarkVersionName
constexpr StringRef MetaRemarkVersionName
Definition: BitstreamRemarkContainer.h:93
llvm::remarks::Remark
A remark type used for both emission and parsing.
Definition: Remark.h:67
llvm::BitstreamWriter::EmitBlockInfoAbbrev
unsigned EmitBlockInfoAbbrev(unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv)
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID.
Definition: BitstreamWriter.h:606
llvm::remarks::MetaSerializer::emit
virtual void emit()=0
llvm::BitCodeAbbrevOp::Blob
@ Blob
Definition: BitCodes.h:43
llvm::remarks::RemarkSerializer
This is the base class for a remark serializer.
Definition: RemarkSerializer.h:42
llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkArgWithDebugLocAbbrevID
uint64_t RecordRemarkArgWithDebugLocAbbrevID
Definition: BitstreamRemarkSerializer.h:73
llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkArgWithoutDebugLocAbbrevID
uint64_t RecordRemarkArgWithoutDebugLocAbbrevID
Definition: BitstreamRemarkSerializer.h:74
llvm::remarks
Definition: AsmPrinter.h:79
llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkDebugLocAbbrevID
uint64_t RecordRemarkDebugLocAbbrevID
Definition: BitstreamRemarkSerializer.h:71
llvm::remarks::RECORD_REMARK_HEADER
@ RECORD_REMARK_HEADER
Definition: BitstreamRemarkContainer.h:82
llvm::remarks::BitstreamMetaSerializer::ExternalFilename
std::optional< StringRef > ExternalFilename
Definition: BitstreamRemarkSerializer.h:171
uint64_t
llvm::BitstreamWriter::EnterBlockInfoBlock
void EnterBlockInfoBlock()
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.
Definition: BitstreamWriter.h:576
llvm::remarks::BitstreamRemarkContainerType::Standalone
@ Standalone
Everything is emitted together.
llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaBlockInfo
void setupMetaBlockInfo()
Set up the block info for the metadata block.
Definition: BitstreamRemarkSerializer.cpp:48
llvm::remarks::BitstreamRemarkSerializer::emit
void emit(const Remark &Remark) override
Emit a remark to the stream.
Definition: BitstreamRemarkSerializer.cpp:350
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::remarks::BitstreamRemarkSerializerHelper::setupBlockInfo
void setupBlockInfo()
Set up the necessary block info entries according to the container type.
Definition: BitstreamRemarkSerializer.cpp:197
llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaExternalFile
void setupMetaExternalFile()
The external file in the metadata block.
Definition: BitstreamRemarkSerializer.cpp:108
llvm::remarks::Remark::Hotness
std::optional< uint64_t > Hotness
If profile information is available, this is the number of times the corresponding code was executed ...
Definition: Remark.h:87
llvm::remarks::RECORD_REMARK_HOTNESS
@ RECORD_REMARK_HOTNESS
Definition: BitstreamRemarkContainer.h:84
llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaStrTab
void emitMetaStrTab(const StringTable &StrTab)
Definition: BitstreamRemarkSerializer.cpp:94
llvm::BitCodeAbbrevOp::VBR
@ VBR
Definition: BitCodes.h:40
llvm::remarks::CurrentContainerVersion
constexpr uint64_t CurrentContainerVersion
The current version of the remark container.
Definition: BitstreamRemarkContainer.h:26
llvm::BitstreamWriter::ExitBlock
void ExitBlock()
Definition: BitstreamWriter.h:303
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaStrTab
void setupMetaStrTab()
The strtab in the metadata block.
Definition: BitstreamRemarkSerializer.cpp:84
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
llvm::bitc::BLOCKINFO_CODE_SETBID
@ BLOCKINFO_CODE_SETBID
Definition: BitCodeEnums.h:81
llvm::remarks::RemarkBlockName
constexpr StringRef RemarkBlockName
Definition: BitstreamRemarkContainer.h:71
llvm::remarks::BitstreamRemarkContainerType::SeparateRemarksMeta
@ SeparateRemarksMeta
The metadata emitted separately.
llvm::remarks::MetaSerializer::OS
raw_ostream & OS
The open raw_ostream that the metadata is emitted to.
Definition: RemarkSerializer.h:70
llvm::remarks::META_BLOCK_ID
@ META_BLOCK_ID
The metadata block is mandatory.
Definition: BitstreamRemarkContainer.h:64
llvm::remarks::RECORD_META_STRTAB
@ RECORD_META_STRTAB
Definition: BitstreamRemarkContainer.h:79
llvm::remarks::REMARK_BLOCK_ID
@ REMARK_BLOCK_ID
One remark entry is represented using a REMARK_BLOCK.
Definition: BitstreamRemarkContainer.h:67
llvm::bitc::BLOCKINFO_CODE_BLOCKNAME
@ BLOCKINFO_CODE_BLOCKNAME
Definition: BitCodeEnums.h:82
llvm::remarks::ContainerMagic
constexpr StringLiteral ContainerMagic("RMRK")
The magic number used for identifying remark blocks.
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::remarks::RECORD_REMARK_ARG_WITHOUT_DEBUGLOC
@ RECORD_REMARK_ARG_WITHOUT_DEBUGLOC
Definition: BitstreamRemarkContainer.h:86
BitstreamRemarkSerializer.h
llvm::remarks::BitstreamRemarkSerializer::BitstreamRemarkSerializer
BitstreamRemarkSerializer(raw_ostream &OS, SerializerMode Mode)
Construct a serializer that will create its own string table.
Definition: BitstreamRemarkSerializer.cpp:329
llvm::remarks::MetaExternalFileName
constexpr StringRef MetaExternalFileName
Definition: BitstreamRemarkContainer.h:95
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:2014
llvm::remarks::RemarkHotnessName
constexpr StringRef RemarkHotnessName
Definition: BitstreamRemarkContainer.h:98
llvm::remarks::BitstreamRemarkSerializerHelper::flushToStream
void flushToStream(raw_ostream &OS)
Finalize the writing to OS.
Definition: BitstreamRemarkSerializer.cpp:320
llvm::remarks::MetaStrTabName
constexpr StringRef MetaStrTabName
Definition: BitstreamRemarkContainer.h:94
llvm::remarks::RECORD_META_REMARK_VERSION
@ RECORD_META_REMARK_VERSION
Definition: BitstreamRemarkContainer.h:78
llvm::remarks::MetaSerializer
This is the base class for a remark metadata serializer.
Definition: RemarkSerializer.h:68
llvm::remarks::RemarkDebugLocName
constexpr StringRef RemarkDebugLocName
Definition: BitstreamRemarkContainer.h:97
llvm::remarks::Argument
A key-value pair with a debug location that is used to display the remarks at the right place in the ...
Definition: Remark.h:42
llvm::remarks::StringTable::add
std::pair< unsigned, StringRef > add(StringRef Str)
Add a string to the table. It returns an unique ID of the string.
Definition: RemarkStringTable.cpp:31
llvm::remarks::MetaContainerInfoName
constexpr StringRef MetaContainerInfoName
Definition: BitstreamRemarkContainer.h:92
llvm::BitstreamWriter::EmitRecordWithAbbrev
void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals)
EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
Definition: BitstreamWriter.h:504
llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaBlock
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.
Definition: BitstreamRemarkSerializer.cpp:234
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:614
llvm::BitCodeAbbrevOp
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
Definition: BitCodes.h:33
llvm::remarks::Remark::RemarkType
Type RemarkType
The type of the remark.
Definition: Remark.h:69
llvm::remarks::BitstreamRemarkSerializerHelper::ContainerType
BitstreamRemarkContainerType ContainerType
The type of the container we are serializing.
Definition: BitstreamRemarkSerializer.h:60
llvm::remarks::BitstreamRemarkSerializer::metaSerializer
std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, std::optional< StringRef > ExternalFilename=std::nullopt) override
The metadata serializer associated to this remark serializer.
Definition: BitstreamRemarkSerializer.cpp:371
llvm::remarks::Remark::RemarkName
StringRef RemarkName
Textual identifier for the remark (single-word, camel-case).
Definition: Remark.h:77
llvm::remarks::CurrentRemarkVersion
constexpr uint64_t CurrentRemarkVersion
The current version of the remark entry.
Definition: Remark.h:27
llvm::remarks::BitstreamMetaSerializer
Serializer of metadata for bitstream remarks.
Definition: BitstreamRemarkSerializer.h:160
llvm::SmallVectorImpl< uint64_t >
setRecordName
static void setRecordName(unsigned RecordID, BitstreamWriter &Bitstream, SmallVectorImpl< uint64_t > &R, StringRef Str)
Definition: BitstreamRemarkSerializer.cpp:29
llvm::remarks::BitstreamRemarkContainerType::SeparateRemarksFile
@ SeparateRemarksFile
The remarks emitted separately.
llvm::remarks::BitstreamMetaSerializer::emit
void emit() override
Definition: BitstreamRemarkSerializer.cpp:384
llvm::remarks::RemarkSerializer::StrTab
std::optional< StringTable > StrTab
The string table containing all the unique strings used in the output.
Definition: RemarkSerializer.h:51
llvm::raw_string_ostream::str
std::string & str()
Returns the string's reference.
Definition: raw_ostream.h:660
llvm::remarks::BitstreamRemarkSerializerHelper::getBuffer
StringRef getBuffer()
Finalize the writing to a buffer.
Definition: BitstreamRemarkSerializer.cpp:325
llvm::remarks::BitstreamRemarkSerializerHelper::RecordRemarkHotnessAbbrevID
uint64_t RecordRemarkHotnessAbbrevID
Definition: BitstreamRemarkSerializer.h:72
llvm::remarks::BitstreamRemarkSerializerHelper::Encoded
SmallVector< char, 1024 > Encoded
Buffer used for encoding the bitstream before writing it to the final stream.
Definition: BitstreamRemarkSerializer.h:54
llvm::remarks::BitstreamRemarkContainerType
BitstreamRemarkContainerType
Type of the remark container.
Definition: BitstreamRemarkContainer.h:35
llvm::remarks::Format
Format
The format used for serializing/deserializing remarks.
Definition: RemarkFormat.h:25