LLVM 22.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 switch (RemarksFormat) {
23 case Format::Unknown:
24 case Format::Auto:
25 return createStringError(std::errc::invalid_argument,
26 "Invalid remark serializer format.");
27 case Format::YAML:
28 return std::make_unique<YAMLRemarkSerializer>(OS);
30 return std::make_unique<BitstreamRemarkSerializer>(OS);
31 }
32 llvm_unreachable("Unknown remarks::Format enum");
33}
34
37 remarks::StringTable StrTab) {
38 switch (RemarksFormat) {
39 case Format::Unknown:
40 case Format::Auto:
41 return createStringError(std::errc::invalid_argument,
42 "Invalid remark serializer format.");
43 case Format::YAML:
44 return std::make_unique<YAMLRemarkSerializer>(OS, std::move(StrTab));
46 return std::make_unique<BitstreamRemarkSerializer>(OS, std::move(StrTab));
47 }
48 llvm_unreachable("Unknown remarks::Format enum");
49}
Tagged union holding either a T or a Error.
Definition Error.h:485
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Format
The format used for serializing/deserializing remarks.
LLVM_ABI Expected< std::unique_ptr< RemarkSerializer > > createRemarkSerializer(Format RemarksFormat, raw_ostream &OS)
Create a remark serializer.
This is an optimization pass for GlobalISel generic memory operations.
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:1305
The string table used for serializing remarks.