28 "Emit a section containing remark diagnostics metadata. By default, " 29 "this is enabled for the following formats: yaml-strtab, bitstream."),
33 std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer,
35 : PassFilter(), RemarkSerializer(
std::move(RemarkSerializer)),
40 std::string RegexError;
44 PassFilter = std::move(R);
95 R.
Args.emplace_back();
112 RemarkSerializer->emit(R);
131 switch (RemarkSerializer->SerializerFormat) {
148 unsigned RemarksHotnessThreshold) {
149 if (RemarksWithHotness)
152 if (RemarksHotnessThreshold)
155 if (RemarksFilename.
empty())
160 return make_error<RemarkSetupFormatError>(std::move(
E));
175 if (
Error E = RemarkSerializer.takeError())
176 return make_error<RemarkSetupFormatError>(std::move(
E));
179 std::move(*RemarkSerializer), RemarksFilename));
181 if (!RemarksPasses.
empty())
183 return make_error<RemarkSetupPatternError>(std::move(
E));
185 return std::move(RemarksFile);
192 unsigned RemarksHotnessThreshold) {
193 if (RemarksWithHotness)
196 if (RemarksHotnessThreshold)
201 return make_error<RemarkSetupFormatError>(std::move(
E));
207 return make_error<RemarkSetupFormatError>(std::move(
E));
210 std::make_unique<RemarkStreamer>(std::move(*RemarkSerializer)));
212 if (!RemarksPasses.
empty())
214 return make_error<RemarkSetupPatternError>(std::move(
E));
DiagnosticKind
Defines the different supported kind of a diagnostic.
void setRemarkStreamer(std::unique_ptr< RemarkStreamer > RemarkStreamer)
Set the diagnostics output used for optimization diagnostics.
This class represents lattice values for constants.
cl::opt< bool > RemarksWithHotness("lto-pass-remarks-with-hotness", cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden)
RemarkStreamer * getRemarkStreamer()
Return the streamer used by the backend to save remark diagnostics.
Error takeError()
Take ownership of the stored error.
void setDiagnosticsHotnessThreshold(uint64_t Threshold)
Set the minimum hotness value a diagnostic needs in order to be included in optimization diagnostics...
cl::opt< std::string > RemarksPasses("lto-pass-remarks-filter", cl::desc("Only record optimization remarks from passes whose " "names match the given regular expression"), cl::value_desc("regex"))
std::error_code make_error_code(BitcodeError E)
Tagged union holding either a T or a Error.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void setDiagnosticsHotnessRequested(bool Requested)
Set if a code hotness metric should be included in optimization diagnostics.
The file should be opened in text mode on platforms that make this distinction.
initializer< Ty > init(const Ty &Val)
const Function & getFunction() const
This is an important class for using LLVM in a threaded context.
Instrumentation for Order File
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void getLocation(StringRef &RelativePath, unsigned &Line, unsigned &Column) const
Return location information for this diagnostic in three parts: the relative source file path...
Used in the streaming interface as the general argument type.
static ErrorSuccess success()
Create a success value.
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, if any.
StringRef getRelativePath() const
Return the file name relative to the compilation directory.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
Expected< std::unique_ptr< ToolOutputFile > > setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, unsigned RemarksHotnessThreshold=0)
Setup optimization remarks that output to a file.
StringRef getRemarkName() const
ArrayRef< Argument > getArgs() const
StringRef getName() const
Return a constant reference to the value's name.
Optional< uint64_t > getHotness() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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"))
cl::opt< std::string > RemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), cl::value_desc("filename"))
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
unsigned getColumn() const
StringRef getPassName() const