LLVM 20.0.0git
RemarkStreamer.cpp
Go to the documentation of this file.
1//===- llvm/Remarks/RemarkStreamer.cpp - Remark Streamer -*- C++ --------*-===//
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 contains the implementation of the main remark streamer.
10//
11//===----------------------------------------------------------------------===//
12
15#include <optional>
16
17using namespace llvm;
18using namespace llvm::remarks;
19
21 "remarks-section",
23 "Emit a section containing remark diagnostics metadata. By default, "
24 "this is enabled for the following formats: yaml-strtab, bitstream."),
26
28 std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer,
29 std::optional<StringRef> FilenameIn)
31 Filename(FilenameIn ? std::optional<std::string>(FilenameIn->str())
32 : std::nullopt) {}
33
35 Regex R = Regex(Filter);
36 std::string RegexError;
37 if (!R.isValid(RegexError))
38 return createStringError(std::make_error_code(std::errc::invalid_argument),
39 RegexError.data());
40 PassFilter = std::move(R);
41 return Error::success();
42}
43
45 if (PassFilter)
46 return PassFilter->match(Str);
47 // No filter means all strings pass.
48 return true;
49}
50
53 return true;
54
56 return false;
57
59
60 // We only need a section if we're in separate mode.
62 return false;
63
64 // Only some formats need a section:
65 // * bitstream
66 // * yaml-strtab
70 return true;
71 default:
72 return false;
73 }
74}
static cl::opt< cl::boolOrDefault > EnableRemarksSection("remarks-section", cl::desc("Emit a section containing remark diagnostics metadata. By default, " "this is enabled for the following formats: yaml-strtab, bitstream."), cl::init(cl::BOU_UNSET), cl::Hidden)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Error setFilter(StringRef Filter)
Set a pass filter based on a regex Filter.
bool needsSection() const
Check if the remarks also need to have associated metadata in a section.
RemarkStreamer(std::unique_ptr< remarks::RemarkSerializer > RemarkSerializer, std::optional< StringRef > Filename=std::nullopt)
bool matchesFilter(StringRef Str)
Check wether the string matches the filter.
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1286
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1856
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
This is the base class for a remark serializer.
Format SerializerFormat
The format of the serializer.
SerializerMode Mode
The serialization mode.