LLVM 19.0.0git
RemarkSerializer.cpp
Go to the documentation of this file.
1//===- RemarkSerializer.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 tools for serializing remarks.
10//
11//===----------------------------------------------------------------------===//
12
16
17using namespace llvm;
18using namespace llvm::remarks;
19
22 raw_ostream &OS) {
23 switch (RemarksFormat) {
24 case Format::Unknown:
25 return createStringError(std::errc::invalid_argument,
26 "Unknown remark serializer format.");
27 case Format::YAML:
28 return std::make_unique<YAMLRemarkSerializer>(OS, Mode);
29 case Format::YAMLStrTab:
30 return std::make_unique<YAMLStrTabRemarkSerializer>(OS, Mode);
31 case Format::Bitstream:
32 return std::make_unique<BitstreamRemarkSerializer>(OS, Mode);
33 }
34 llvm_unreachable("Unknown remarks::Format enum");
35}
36
40 switch (RemarksFormat) {
41 case Format::Unknown:
42 return createStringError(std::errc::invalid_argument,
43 "Unknown remark serializer format.");
44 case Format::YAML:
45 return std::make_unique<YAMLRemarkSerializer>(OS, Mode, std::move(StrTab));
46 case Format::YAMLStrTab:
47 return std::make_unique<YAMLStrTabRemarkSerializer>(OS, Mode,
48 std::move(StrTab));
49 case Format::Bitstream:
50 return std::make_unique<BitstreamRemarkSerializer>(OS, Mode,
51 std::move(StrTab));
52 }
53 llvm_unreachable("Unknown remarks::Format enum");
54}
raw_pwrite_stream & OS
Tagged union holding either a T or a Error.
Definition: Error.h:474
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Expected< std::unique_ptr< RemarkSerializer > > createRemarkSerializer(Format RemarksFormat, SerializerMode Mode, raw_ostream &OS)
Create a remark serializer.
Format
The format used for serializing/deserializing remarks.
Definition: RemarkFormat.h:25
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
cl::opt< std::string > RemarksFormat("lto-pass-remarks-format", cl::desc("The format used for serializing remarks (default: YAML)"), cl::value_desc("format"), cl::init("yaml"))
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1258
The string table used for serializing remarks.