LLVM 22.0.0git
DiagnosticInfo.h
Go to the documentation of this file.
1//===- llvm/IR/DiagnosticInfo.h - Diagnostic Declaration --------*- 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 declares the different classes involved in low level diagnostics.
10//
11// Diagnostics reporting is still done as part of the LLVMContext.
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_DIAGNOSTICINFO_H
15#define LLVM_IR_DIAGNOSTICINFO_H
16
17#include "llvm-c/Types.h"
18#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/IR/DebugLoc.h"
29#include <algorithm>
30#include <cstdint>
31#include <functional>
32#include <iterator>
33#include <optional>
34#include <string>
35#include <utility>
36
37namespace llvm {
38
39// Forward declarations.
41class DIFile;
42class DISubprogram;
43class CallInst;
44class Function;
45class Instruction;
46class InstructionCost;
47class Module;
48class Type;
49class Value;
50
51/// Defines the different supported severity of a diagnostic.
52enum DiagnosticSeverity : char {
56 // A note attaches additional information to one of the previous diagnostic
57 // types.
59};
60
61/// Defines the different supported kind of a diagnostic.
62/// This enum should be extended with a new ID for each added concrete subclass.
100
101/// Get the next available kind ID for a plugin diagnostic.
102/// Each time this function is called, it returns a different number.
103/// Therefore, a plugin that wants to "identify" its own classes
104/// with a dynamic identifier, just have to use this method to get a new ID
105/// and assign it to each of its classes.
106/// The returned ID will be greater than or equal to DK_FirstPluginKind.
107/// Thus, the plugin identifiers will not conflict with the
108/// DiagnosticKind values.
110
111/// This is the base abstract class for diagnostic reporting in
112/// the backend.
113/// The print method must be overloaded by the subclasses to print a
114/// user-friendly message in the client of the backend (let us call it a
115/// frontend).
117private:
118 /// Kind defines the kind of report this is about.
119 const /* DiagnosticKind */ int Kind;
120 /// Severity gives the severity of the diagnostic.
121 const DiagnosticSeverity Severity;
122
123 virtual void anchor();
124public:
125 DiagnosticInfo(/* DiagnosticKind */ int Kind, DiagnosticSeverity Severity)
126 : Kind(Kind), Severity(Severity) {}
127
128 virtual ~DiagnosticInfo() = default;
129
130 /* DiagnosticKind */ int getKind() const { return Kind; }
131 DiagnosticSeverity getSeverity() const { return Severity; }
132
133 /// Print using the given \p DP a user-friendly message.
134 /// This is the default message that will be printed to the user.
135 /// It is used when the frontend does not directly take advantage
136 /// of the information contained in fields of the subclasses.
137 /// The printed message must not end with '.' nor start with a severity
138 /// keyword.
139 virtual void print(DiagnosticPrinter &DP) const = 0;
140};
141
142using DiagnosticHandlerFunction = std::function<void(const DiagnosticInfo &)>;
143
145 const Twine &MsgStr;
146 const Instruction *Inst = nullptr;
147
148public:
149 /// \p MsgStr is the message to be reported to the frontend.
150 /// This class does not copy \p MsgStr, therefore the reference must be valid
151 /// for the whole life time of the Diagnostic.
153 DiagnosticSeverity Severity = DS_Error)
154 : DiagnosticInfo(DK_Generic, Severity), MsgStr(MsgStr) {}
155
157 const Twine &ErrMsg LLVM_LIFETIME_BOUND,
158 DiagnosticSeverity Severity = DS_Error)
159 : DiagnosticInfo(DK_Generic, Severity), MsgStr(ErrMsg), Inst(I) {}
160
161 const Twine &getMsgStr() const { return MsgStr; }
162 const Instruction *getInstruction() const { return Inst; }
163
164 /// \see DiagnosticInfo::print.
165 void print(DiagnosticPrinter &DP) const override;
166
167 static bool classof(const DiagnosticInfo *DI) {
168 return DI->getKind() == DK_Generic;
169 }
170};
171
172/// Diagnostic information for inline asm reporting.
173/// This is basically a message and an optional location.
175private:
176 /// Optional line information. 0 if not set.
177 uint64_t LocCookie = 0;
178 /// Message to be reported.
179 const Twine &MsgStr;
180 /// Optional origin of the problem.
181 const Instruction *Instr = nullptr;
182
183public:
184 /// \p LocCookie if non-zero gives the line number for this report.
185 /// \p MsgStr gives the message.
186 /// This class does not copy \p MsgStr, therefore the reference must be valid
187 /// for the whole life time of the Diagnostic.
189 const Twine &MsgStr LLVM_LIFETIME_BOUND,
190 DiagnosticSeverity Severity = DS_Error);
191
192 /// \p Instr gives the original instruction that triggered the diagnostic.
193 /// \p MsgStr gives the message.
194 /// This class does not copy \p MsgStr, therefore the reference must be valid
195 /// for the whole life time of the Diagnostic.
196 /// Same for \p I.
198 const Twine &MsgStr LLVM_LIFETIME_BOUND,
199 DiagnosticSeverity Severity = DS_Error);
200
201 uint64_t getLocCookie() const { return LocCookie; }
202 const Twine &getMsgStr() const { return MsgStr; }
203 const Instruction *getInstruction() const { return Instr; }
204
205 /// \see DiagnosticInfo::print.
206 void print(DiagnosticPrinter &DP) const override;
207
208 static bool classof(const DiagnosticInfo *DI) {
209 return DI->getKind() == DK_InlineAsm;
210 }
211};
212
213/// Diagnostic information for debug metadata version reporting.
214/// This is basically a module and a version.
216private:
217 /// The module that is concerned by this debug metadata version diagnostic.
218 const Module &M;
219 /// The actual metadata version.
220 unsigned MetadataVersion;
221
222public:
223 /// \p The module that is concerned by this debug metadata version diagnostic.
224 /// \p The actual metadata version.
225 DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion,
227 : DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M),
228 MetadataVersion(MetadataVersion) {}
229
230 const Module &getModule() const { return M; }
231 unsigned getMetadataVersion() const { return MetadataVersion; }
232
233 /// \see DiagnosticInfo::print.
234 void print(DiagnosticPrinter &DP) const override;
235
236 static bool classof(const DiagnosticInfo *DI) {
237 return DI->getKind() == DK_DebugMetadataVersion;
238 }
239};
240
241/// Diagnostic information for stripping invalid debug metadata.
243 : public DiagnosticInfo {
244private:
245 /// The module that is concerned by this debug metadata version diagnostic.
246 const Module &M;
247
248public:
249 /// \p The module that is concerned by this debug metadata version diagnostic.
253
254 const Module &getModule() const { return M; }
255
256 /// \see DiagnosticInfo::print.
257 void print(DiagnosticPrinter &DP) const override;
258
259 static bool classof(const DiagnosticInfo *DI) {
260 return DI->getKind() == DK_DebugMetadataInvalid;
261 }
262};
263
264/// Diagnostic information for the sample profiler.
266public:
267 DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
268 const Twine &Msg LLVM_LIFETIME_BOUND,
269 DiagnosticSeverity Severity = DS_Error)
270 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
271 LineNum(LineNum), Msg(Msg) {}
273 const Twine &Msg LLVM_LIFETIME_BOUND,
274 DiagnosticSeverity Severity = DS_Error)
275 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
276 Msg(Msg) {}
280
281 /// \see DiagnosticInfo::print.
282 void print(DiagnosticPrinter &DP) const override;
283
284 static bool classof(const DiagnosticInfo *DI) {
285 return DI->getKind() == DK_SampleProfile;
286 }
287
288 StringRef getFileName() const { return FileName; }
289 unsigned getLineNum() const { return LineNum; }
290 const Twine &getMsg() const { return Msg; }
291
292private:
293 /// Name of the input file associated with this diagnostic.
294 StringRef FileName;
295
296 /// Line number where the diagnostic occurred. If 0, no line number will
297 /// be emitted in the message.
298 unsigned LineNum = 0;
299
300 /// Message to report.
301 const Twine &Msg;
302};
303
304/// Diagnostic information for the PGO profiler.
306public:
307 DiagnosticInfoPGOProfile(const char *FileName,
308 const Twine &Msg LLVM_LIFETIME_BOUND,
309 DiagnosticSeverity Severity = DS_Error)
310 : DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
311
312 /// \see DiagnosticInfo::print.
313 void print(DiagnosticPrinter &DP) const override;
314
315 static bool classof(const DiagnosticInfo *DI) {
316 return DI->getKind() == DK_PGOProfile;
317 }
318
319 const char *getFileName() const { return FileName; }
320 const Twine &getMsg() const { return Msg; }
321
322private:
323 /// Name of the input file associated with this diagnostic.
324 const char *FileName;
325
326 /// Message to report.
327 const Twine &Msg;
328};
329
331 DIFile *File = nullptr;
332 unsigned Line = 0;
333 unsigned Column = 0;
334
335public:
339
340 bool isValid() const { return File; }
341 /// Return the full path to the file.
342 LLVM_ABI std::string getAbsolutePath() const;
343 /// Return the file name relative to the compilation directory.
345 unsigned getLine() const { return Line; }
346 unsigned getColumn() const { return Column; }
347};
348
349/// Common features for diagnostics with an associated location.
351 void anchor() override;
352public:
353 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
354 /// the location information to use in the diagnostic.
356 enum DiagnosticSeverity Severity,
357 const Function &Fn,
358 const DiagnosticLocation &Loc)
359 : DiagnosticInfo(Kind, Severity), Fn(Fn), Loc(Loc) {}
360
361 /// Return true if location information is available for this diagnostic.
362 bool isLocationAvailable() const { return Loc.isValid(); }
363
364 /// Return a string with the location information for this diagnostic
365 /// in the format "file:line:col". If location information is not available,
366 /// it returns "<unknown>:0:0".
367 std::string getLocationStr() const;
368
369 /// Return location information for this diagnostic in three parts:
370 /// the relative source file path, line number and column.
371 void getLocation(StringRef &RelativePath, unsigned &Line,
372 unsigned &Column) const;
373
374 /// Return the absolute path tot the file.
375 std::string getAbsolutePath() const;
376
377 const Function &getFunction() const { return Fn; }
378 DiagnosticLocation getLocation() const { return Loc; }
379
380private:
381 /// Function where this diagnostic is triggered.
382 const Function &Fn;
383
384 /// Debug location where this diagnostic is triggered.
386};
387
390private:
391 /// Message to be reported.
392 const Twine &MsgStr;
393
394public:
396 const Function &Fn,
397 const DiagnosticLocation &Loc,
398 DiagnosticSeverity Severity = DS_Error)
400 Loc),
401 MsgStr(MsgStr) {}
402
403 const Twine &getMsgStr() const { return MsgStr; }
404
405 void print(DiagnosticPrinter &DP) const override;
406
407 static bool classof(const DiagnosticInfo *DI) {
408 return DI->getKind() == DK_LegalizationFailure;
409 }
410};
411
414private:
415 /// Message to be reported.
416 const Twine &MsgStr;
417
418public:
419 /// \p MsgStr is the message to be reported to the frontend.
420 /// This class does not copy \p MsgStr, therefore the reference must be valid
421 /// for the whole life time of the Diagnostic.
423 const DiagnosticLocation &Loc,
424 DiagnosticSeverity Severity = DS_Error)
426 MsgStr(MsgStr) {}
427
428 const Twine &getMsgStr() const { return MsgStr; }
429
430 /// \see DiagnosticInfo::print.
431 void print(DiagnosticPrinter &DP) const override;
432
433 static bool classof(const DiagnosticInfo *DI) {
434 return DI->getKind() == DK_GenericWithLoc;
435 }
436};
437
440private:
441 /// Message to be reported.
442 const Twine &MsgStr;
443
444public:
445 /// \p MsgStr is the message to be reported to the frontend.
446 /// This class does not copy \p MsgStr, therefore the reference must be valid
447 /// for the whole life time of the Diagnostic.
448 DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn,
449 const DiagnosticLocation &DL,
450 DiagnosticSeverity Severity = DS_Error);
451
452 DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn,
453 DiagnosticSeverity Severity = DS_Error);
454
455 const Twine &getMsgStr() const { return MsgStr; }
456
457 /// \see DiagnosticInfo::print.
458 void print(DiagnosticPrinter &DP) const override;
459
460 static bool classof(const DiagnosticInfo *DI) {
461 return DI->getKind() == DK_RegAllocFailure;
462 }
463};
464
465/// Diagnostic information for stack size etc. reporting.
466/// This is basically a function and a size.
469private:
470 /// The function that is concerned by this resource limit diagnostic.
471 const Function &Fn;
472
473 /// Description of the resource type (e.g. stack size)
474 const char *ResourceName;
475
476 /// The computed size usage
477 uint64_t ResourceSize;
478
479 // Threshould passed
480 uint64_t ResourceLimit;
481
482public:
483 /// \p The function that is concerned by this stack size diagnostic.
484 /// \p The computed stack size.
485 DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName,
486 uint64_t ResourceSize, uint64_t ResourceLimit,
489
490 const Function &getFunction() const { return Fn; }
491 const char *getResourceName() const { return ResourceName; }
492 uint64_t getResourceSize() const { return ResourceSize; }
493 uint64_t getResourceLimit() const { return ResourceLimit; }
494
495 /// \see DiagnosticInfo::print.
496 void print(DiagnosticPrinter &DP) const override;
497
498 static bool classof(const DiagnosticInfo *DI) {
499 return DI->getKind() == DK_ResourceLimit || DI->getKind() == DK_StackSize;
500 }
501};
502
504 void anchor() override;
505
506public:
508 uint64_t StackLimit,
510 : DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize,
511 StackLimit, Severity, DK_StackSize) {}
512
515
516 static bool classof(const DiagnosticInfo *DI) {
517 return DI->getKind() == DK_StackSize;
518 }
519};
520
521/// Common features for diagnostics dealing with optimization remarks
522/// that are used by both IR and MIR passes.
525public:
526 /// Used to set IsVerbose via the stream interface.
527 struct setIsVerbose {};
528
529 /// When an instance of this is inserted into the stream, the arguments
530 /// following will not appear in the remark printed in the compiler output
531 /// (-Rpass) but only in the optimization record file
532 /// (-fsave-optimization-record).
533 struct setExtraArgs {};
534
535 /// Used in the streaming interface as the general argument type. It
536 /// internally converts everything into a key-value pair.
537 struct Argument {
538 std::string Key;
539 std::string Val;
540 // If set, the debug location corresponding to the value.
542
543 explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
547 Argument(StringRef Key, const char *S) : Argument(Key, StringRef(S)) {};
551 LLVM_ABI Argument(StringRef Key, long long N);
552 LLVM_ABI Argument(StringRef Key, unsigned N);
553 LLVM_ABI Argument(StringRef Key, unsigned long N);
554 LLVM_ABI Argument(StringRef Key, unsigned long long N);
556 Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
560 };
561
562 /// \p PassName is the name of the pass emitting this diagnostic. \p
563 /// RemarkName is a textual identifier for the remark (single-word,
564 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
565 /// \p Loc is the location information to use in the diagnostic. If line table
566 /// information is available, the diagnostic will include the source code
567 /// location.
569 enum DiagnosticSeverity Severity,
570 const char *PassName, StringRef RemarkName,
571 const Function &Fn,
572 const DiagnosticLocation &Loc)
573 : DiagnosticInfoWithLocationBase(Kind, Severity, Fn, Loc),
575
576 void insert(StringRef S);
577 void insert(Argument A);
578 void insert(setIsVerbose V);
579 void insert(setExtraArgs EA);
580
581 /// \see DiagnosticInfo::print.
582 void print(DiagnosticPrinter &DP) const override;
583
584 /// Return true if this optimization remark is enabled by one of
585 /// of the LLVM command line flags (-pass-remarks, -pass-remarks-missed,
586 /// or -pass-remarks-analysis). Note that this only handles the LLVM
587 /// flags. We cannot access Clang flags from here (they are handled
588 /// in BackendConsumer::OptimizationRemarkHandler).
589 virtual bool isEnabled() const = 0;
590
591 StringRef getPassName() const { return PassName; }
593 std::string getMsg() const;
594 std::optional<uint64_t> getHotness() const { return Hotness; }
595 void setHotness(std::optional<uint64_t> H) { Hotness = H; }
596
597 bool isVerbose() const { return IsVerbose; }
598
599 ArrayRef<Argument> getArgs() const { return Args; }
600
601 static bool classof(const DiagnosticInfo *DI) {
602 return (DI->getKind() >= DK_FirstRemark &&
603 DI->getKind() <= DK_LastRemark) ||
604 (DI->getKind() >= DK_FirstMachineRemark &&
606 }
607
608 bool isPassed() const {
609 return (getKind() == DK_OptimizationRemark ||
611 }
612
613 bool isMissed() const {
616 }
617
622
623protected:
624 /// Name of the pass that triggers this report. If this matches the
625 /// regular expression given in -Rpass=regexp, then the remark will
626 /// be emitted.
627 const char *PassName;
628
629 /// Textual identifier for the remark (single-word, CamelCase). Can be used
630 /// by external tools reading the output file for optimization remarks to
631 /// identify the remark.
633
634 /// If profile information is available, this is the number of times the
635 /// corresponding code was executed in a profile instrumentation run.
636 std::optional<uint64_t> Hotness;
637
638 /// Arguments collected via the streaming interface.
640
641 /// The remark is expected to be noisy.
642 bool IsVerbose = false;
643
644 /// If positive, the index of the first argument that only appear in
645 /// the optimization records and not in the remark printed in the compiler
646 /// output.
648};
649
650/// Allow the insertion operator to return the actual remark type rather than a
651/// common base class. This allows returning the result of the insertion
652/// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah".
653template <class RemarkT>
654decltype(auto)
655operator<<(RemarkT &&R,
656 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
657 std::remove_reference_t<RemarkT>>,
658 StringRef>
659 S) {
660 R.insert(S);
661 return std::forward<RemarkT>(R);
662}
663
664template <class RemarkT>
665decltype(auto)
666operator<<(RemarkT &&R,
667 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
668 std::remove_reference_t<RemarkT>>,
670 A) {
671 R.insert(A);
672 return std::forward<RemarkT>(R);
673}
674
675template <class RemarkT>
676decltype(auto)
677operator<<(RemarkT &&R,
678 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
679 std::remove_reference_t<RemarkT>>,
681 V) {
682 R.insert(V);
683 return std::forward<RemarkT>(R);
684}
685
686template <class RemarkT>
687decltype(auto)
688operator<<(RemarkT &&R,
689 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
690 std::remove_reference_t<RemarkT>>,
692 EA) {
693 R.insert(EA);
694 return std::forward<RemarkT>(R);
695}
696
697/// Common features for diagnostics dealing with optimization remarks
698/// that are used by IR passes.
701 void anchor() override;
702public:
703 /// \p PassName is the name of the pass emitting this diagnostic. \p
704 /// RemarkName is a textual identifier for the remark (single-word,
705 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
706 /// \p Loc is the location information to use in the diagnostic. If line table
707 /// information is available, the diagnostic will include the source code
708 /// location. \p CodeRegion is IR value that the optimization operates on.
709 /// This is currently used to provide run-time hotness information with PGO.
711 enum DiagnosticSeverity Severity,
712 const char *PassName, StringRef RemarkName,
713 const Function &Fn,
714 const DiagnosticLocation &Loc,
715 const BasicBlock *CodeRegion = nullptr)
717 Loc),
718 CodeRegion(CodeRegion) {}
719
720 /// This is ctor variant allows a pass to build an optimization remark
721 /// from an existing remark.
722 ///
723 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
724 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
725 /// remark. The string \p Prepend will be emitted before the original
726 /// message.
731 Orig.RemarkName, Orig.getFunction(), Orig.getLocation()),
732 CodeRegion(Orig.getCodeRegion()) {
733 *this << Prepend;
735 }
736
737 /// Legacy interface.
738 /// \p PassName is the name of the pass emitting this diagnostic.
739 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
740 /// the location information to use in the diagnostic. If line table
741 /// information is available, the diagnostic will include the source code
742 /// location. \p Msg is the message to show. Note that this class does not
743 /// copy this message, so this reference must be valid for the whole life time
744 /// of the diagnostic.
746 enum DiagnosticSeverity Severity,
747 const char *PassName, const Function &Fn,
748 const DiagnosticLocation &Loc, const Twine &Msg)
749 : DiagnosticInfoOptimizationBase(Kind, Severity, PassName, "", Fn, Loc) {
750 *this << Msg.str();
751 }
752
753 const BasicBlock *getCodeRegion() const { return CodeRegion; }
754
755 static bool classof(const DiagnosticInfo *DI) {
756 return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
757 }
758
759private:
760 /// The IR region (currently basic block) that the optimization operates on.
761 /// This is currently used to provide run-time hotness information with PGO.
762 const BasicBlock *CodeRegion = nullptr;
763};
764
765/// Diagnostic information for applied optimization remarks.
767public:
768 /// \p PassName is the name of the pass emitting this diagnostic. If this name
769 /// matches the regular expression given in -Rpass=, then the diagnostic will
770 /// be emitted. \p RemarkName is a textual identifier for the remark (single-
771 /// word, CamelCase). \p Loc is the debug location and \p CodeRegion is the
772 /// region that the optimization operates on.
774 const DiagnosticLocation &Loc,
775 const BasicBlock *CodeRegion);
776
777 /// Same as above, but the debug location and code region are derived from \p
778 /// Instr.
780 const Instruction *Inst);
781
782 /// Same as above, but the debug location and code region are derived from \p
783 /// Func.
785 const Function *Func);
786
787 static bool classof(const DiagnosticInfo *DI) {
788 return DI->getKind() == DK_OptimizationRemark;
789 }
790
791 /// \see DiagnosticInfoOptimizationBase::isEnabled.
792 bool isEnabled() const override;
793
794private:
795 /// This is deprecated now and only used by the function API below.
796 /// \p PassName is the name of the pass emitting this diagnostic. If
797 /// this name matches the regular expression given in -Rpass=, then the
798 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
799 /// is being emitted. \p Loc is the location information to use in the
800 /// diagnostic. If line table information is available, the diagnostic
801 /// will include the source code location. \p Msg is the message to show.
802 /// Note that this class does not copy this message, so this reference
803 /// must be valid for the whole life time of the diagnostic.
804 OptimizationRemark(const char *PassName, const Function &Fn,
805 const DiagnosticLocation &Loc, const Twine &Msg)
807 Fn, Loc, Msg) {}
808};
809
810/// Diagnostic information for missed-optimization remarks.
812public:
813 /// \p PassName is the name of the pass emitting this diagnostic. If this name
814 /// matches the regular expression given in -Rpass-missed=, then the
815 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
816 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
817 /// CodeRegion is the region that the optimization operates on.
819 const DiagnosticLocation &Loc,
820 const BasicBlock *CodeRegion);
821
822 /// Same as above but \p Inst is used to derive code region and debug
823 /// location.
825 const Instruction *Inst);
826
827 /// Same as above but \p F is used to derive code region and debug
828 /// location.
830 const Function *F);
831
832 static bool classof(const DiagnosticInfo *DI) {
833 return DI->getKind() == DK_OptimizationRemarkMissed;
834 }
835
836 /// \see DiagnosticInfoOptimizationBase::isEnabled.
837 bool isEnabled() const override;
838
839private:
840 /// This is deprecated now and only used by the function API below.
841 /// \p PassName is the name of the pass emitting this diagnostic. If
842 /// this name matches the regular expression given in -Rpass-missed=, then the
843 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
844 /// is being emitted. \p Loc is the location information to use in the
845 /// diagnostic. If line table information is available, the diagnostic
846 /// will include the source code location. \p Msg is the message to show.
847 /// Note that this class does not copy this message, so this reference
848 /// must be valid for the whole life time of the diagnostic.
849 OptimizationRemarkMissed(const char *PassName, const Function &Fn,
850 const DiagnosticLocation &Loc, const Twine &Msg)
852 PassName, Fn, Loc, Msg) {}
853};
854
855/// Diagnostic information for optimization analysis remarks.
858public:
859 /// \p PassName is the name of the pass emitting this diagnostic. If this name
860 /// matches the regular expression given in -Rpass-analysis=, then the
861 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
862 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
863 /// CodeRegion is the region that the optimization operates on.
865 const DiagnosticLocation &Loc,
866 const BasicBlock *CodeRegion);
867
868 /// This is ctor variant allows a pass to build an optimization remark
869 /// from an existing remark.
870 ///
871 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
872 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
873 /// remark. The string \p Prepend will be emitted before the original
874 /// message.
878
879 /// Same as above but \p Inst is used to derive code region and debug
880 /// location.
881 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
882 const Instruction *Inst);
883
884 /// Same as above but \p F is used to derive code region and debug
885 /// location.
886 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
887 const Function *F);
888
889 static bool classof(const DiagnosticInfo *DI) {
891 }
892
893 /// \see DiagnosticInfoOptimizationBase::isEnabled.
894 bool isEnabled() const override;
895
896 static const char *AlwaysPrint;
897
898 bool shouldAlwaysPrint() const { return getPassName() == AlwaysPrint; }
899
900protected:
902 const Function &Fn, const DiagnosticLocation &Loc,
903 const Twine &Msg)
905
907 StringRef RemarkName,
908 const DiagnosticLocation &Loc,
909 const BasicBlock *CodeRegion);
910
911private:
912 /// This is deprecated now and only used by the function API below.
913 /// \p PassName is the name of the pass emitting this diagnostic. If
914 /// this name matches the regular expression given in -Rpass-analysis=, then
915 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
916 /// is being emitted. \p Loc is the location information to use in the
917 /// diagnostic. If line table information is available, the diagnostic will
918 /// include the source code location. \p Msg is the message to show. Note that
919 /// this class does not copy this message, so this reference must be valid for
920 /// the whole life time of the diagnostic.
921 OptimizationRemarkAnalysis(const char *PassName, const Function &Fn,
922 const DiagnosticLocation &Loc, const Twine &Msg)
924 PassName, Fn, Loc, Msg) {}
925};
926
927/// Diagnostic information for optimization analysis remarks related to
928/// floating-point non-commutativity.
931 void anchor() override;
932public:
933 /// \p PassName is the name of the pass emitting this diagnostic. If this name
934 /// matches the regular expression given in -Rpass-analysis=, then the
935 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
936 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
937 /// CodeRegion is the region that the optimization operates on. The front-end
938 /// will append its own message related to options that address floating-point
939 /// non-commutativity.
946
947 static bool classof(const DiagnosticInfo *DI) {
949 }
950
951private:
952 /// This is deprecated now and only used by the function API below.
953 /// \p PassName is the name of the pass emitting this diagnostic. If
954 /// this name matches the regular expression given in -Rpass-analysis=, then
955 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
956 /// is being emitted. \p Loc is the location information to use in the
957 /// diagnostic. If line table information is available, the diagnostic will
958 /// include the source code location. \p Msg is the message to show. The
959 /// front-end will append its own message related to options that address
960 /// floating-point non-commutativity. Note that this class does not copy this
961 /// message, so this reference must be valid for the whole life time of the
962 /// diagnostic.
964 const DiagnosticLocation &Loc,
965 const Twine &Msg)
967 PassName, Fn, Loc, Msg) {}
968};
969
970/// Diagnostic information for optimization analysis remarks related to
971/// pointer aliasing.
974 void anchor() override;
975public:
976 /// \p PassName is the name of the pass emitting this diagnostic. If this name
977 /// matches the regular expression given in -Rpass-analysis=, then the
978 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
979 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
980 /// CodeRegion is the region that the optimization operates on. The front-end
981 /// will append its own message related to options that address pointer
982 /// aliasing legality.
988
989 static bool classof(const DiagnosticInfo *DI) {
991 }
992
993private:
994 /// This is deprecated now and only used by the function API below.
995 /// \p PassName is the name of the pass emitting this diagnostic. If
996 /// this name matches the regular expression given in -Rpass-analysis=, then
997 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
998 /// is being emitted. \p Loc is the location information to use in the
999 /// diagnostic. If line table information is available, the diagnostic will
1000 /// include the source code location. \p Msg is the message to show. The
1001 /// front-end will append its own message related to options that address
1002 /// pointer aliasing legality. Note that this class does not copy this
1003 /// message, so this reference must be valid for the whole life time of the
1004 /// diagnostic.
1006 const DiagnosticLocation &Loc,
1007 const Twine &Msg)
1009 PassName, Fn, Loc, Msg) {}
1010};
1011
1012/// Diagnostic information for machine IR parser.
1013// FIXME: Remove this, use DiagnosticInfoSrcMgr instead.
1015 const SMDiagnostic &Diagnostic;
1016
1017public:
1019 const SMDiagnostic &Diagnostic)
1020 : DiagnosticInfo(DK_MIRParser, Severity), Diagnostic(Diagnostic) {}
1021
1022 const SMDiagnostic &getDiagnostic() const { return Diagnostic; }
1023
1024 void print(DiagnosticPrinter &DP) const override;
1025
1026 static bool classof(const DiagnosticInfo *DI) {
1027 return DI->getKind() == DK_MIRParser;
1028 }
1029};
1030
1031/// Diagnostic information for IR instrumentation reporting.
1033 const Twine &Msg;
1034
1035public:
1037 DiagnosticSeverity Severity = DS_Warning)
1038 : DiagnosticInfo(DK_Instrumentation, Severity), Msg(DiagMsg) {}
1039
1040 void print(DiagnosticPrinter &DP) const override;
1041
1042 static bool classof(const DiagnosticInfo *DI) {
1043 return DI->getKind() == DK_Instrumentation;
1044 }
1045};
1046
1047/// Diagnostic information for ISel fallback path.
1049 /// The function that is concerned by this diagnostic.
1050 const Function &Fn;
1051
1052public:
1054 DiagnosticSeverity Severity = DS_Warning)
1055 : DiagnosticInfo(DK_ISelFallback, Severity), Fn(Fn) {}
1056
1057 const Function &getFunction() const { return Fn; }
1058
1059 void print(DiagnosticPrinter &DP) const override;
1060
1061 static bool classof(const DiagnosticInfo *DI) {
1062 return DI->getKind() == DK_ISelFallback;
1063 }
1064};
1065
1066// Create wrappers for C Binding types (see CBindingWrapping.h).
1068
1069/// Diagnostic information for optimization failures.
1072public:
1073 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1074 /// the location information to use in the diagnostic. If line table
1075 /// information is available, the diagnostic will include the source code
1076 /// location. \p Msg is the message to show. Note that this class does not
1077 /// copy this message, so this reference must be valid for the whole life time
1078 /// of the diagnostic.
1084
1085 /// \p PassName is the name of the pass emitting this diagnostic. \p
1086 /// RemarkName is a textual identifier for the remark (single-word,
1087 /// CamelCase). \p Loc is the debug location and \p CodeRegion is the
1088 /// region that the optimization operates on.
1090 const DiagnosticLocation &Loc,
1091 const BasicBlock *CodeRegion);
1092
1093 static bool classof(const DiagnosticInfo *DI) {
1094 return DI->getKind() == DK_OptimizationFailure;
1095 }
1096
1097 /// \see DiagnosticInfoOptimizationBase::isEnabled.
1098 bool isEnabled() const override;
1099};
1100
1101/// Diagnostic information for unsupported feature in backend.
1104private:
1105 const Twine &Msg;
1106
1107public:
1108 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1109 /// the location information to use in the diagnostic. If line table
1110 /// information is available, the diagnostic will include the source code
1111 /// location. \p Msg is the message to show. Note that this class does not
1112 /// copy this message, so this reference must be valid for the whole life time
1113 /// of the diagnostic.
1115 const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
1117 DiagnosticSeverity Severity = DS_Error)
1118 : DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
1119 Msg(Msg) {}
1120
1121 static bool classof(const DiagnosticInfo *DI) {
1122 return DI->getKind() == DK_Unsupported;
1123 }
1124
1125 const Twine &getMessage() const { return Msg; }
1126
1127 void print(DiagnosticPrinter &DP) const override;
1128};
1129
1130/// Diagnostic information for MisExpect analysis.
1132public:
1134 const Twine &Msg LLVM_LIFETIME_BOUND);
1135
1136 /// \see DiagnosticInfo::print.
1137 void print(DiagnosticPrinter &DP) const override;
1138
1139 static bool classof(const DiagnosticInfo *DI) {
1140 return DI->getKind() == DK_MisExpect;
1141 }
1142
1143 const Twine &getMsg() const { return Msg; }
1144
1145private:
1146 /// Message to report.
1147 const Twine &Msg;
1148};
1149
1151 switch (DK) {
1153 return DS_Error;
1154 break;
1156 return DS_Warning;
1157 break;
1159 return DS_Note;
1160 break;
1162 return DS_Remark;
1163 break;
1164 }
1165 llvm_unreachable("unknown SourceMgr::DiagKind");
1166}
1167
1168/// Diagnostic information for SMDiagnostic reporting.
1170 const SMDiagnostic &Diagnostic;
1171 StringRef ModName;
1172
1173 // For inlineasm !srcloc translation.
1174 bool InlineAsmDiag;
1175 uint64_t LocCookie;
1176
1177public:
1178 DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName,
1179 bool InlineAsmDiag = true, uint64_t LocCookie = 0)
1181 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1182 LocCookie(LocCookie) {}
1183
1184 StringRef getModuleName() const { return ModName; }
1185 bool isInlineAsmDiag() const { return InlineAsmDiag; }
1186 const SMDiagnostic &getSMDiag() const { return Diagnostic; }
1187 uint64_t getLocCookie() const { return LocCookie; }
1188 void print(DiagnosticPrinter &DP) const override;
1189
1190 static bool classof(const DiagnosticInfo *DI) {
1191 return DI->getKind() == DK_SrcMgr;
1192 }
1193};
1194
1195LLVM_ABI void diagnoseDontCall(const CallInst &CI);
1196
1198 StringRef CalleeName;
1199 StringRef Note;
1200 uint64_t LocCookie;
1201
1202public:
1204 DiagnosticSeverity DS, uint64_t LocCookie)
1205 : DiagnosticInfo(DK_DontCall, DS), CalleeName(CalleeName), Note(Note),
1206 LocCookie(LocCookie) {}
1207 StringRef getFunctionName() const { return CalleeName; }
1208 StringRef getNote() const { return Note; }
1209 uint64_t getLocCookie() const { return LocCookie; }
1210 void print(DiagnosticPrinter &DP) const override;
1211 static bool classof(const DiagnosticInfo *DI) {
1212 return DI->getKind() == DK_DontCall;
1213 }
1214};
1215
1216} // end namespace llvm
1217
1218#endif // LLVM_IR_DIAGNOSTICINFO_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_LIFETIME_BOUND
Definition Compiler.h:435
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
#define H(x, y, z)
Definition MD5.cpp:57
#define T
#define P(N)
static llvm::Expected< std::string > getAbsolutePath(StringRef Authority, StringRef Body)
Definition Protocol.cpp:162
static MemoryLocation getLocation(Instruction *I)
This file defines the SmallVector class.
static const char PassName[]
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class represents a function call, abstracting a target machine's calling convention.
Subprogram description. Uses SubclassData1.
A debug info location.
Definition DebugLoc.h:124
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion, DiagnosticSeverity Severity=DS_Warning)
The module that is concerned by this debug metadata version diagnostic.
DiagnosticInfoDontCall(StringRef CalleeName, StringRef Note, DiagnosticSeverity DS, uint64_t LocCookie)
static bool classof(const DiagnosticInfo *DI)
StringRef getFunctionName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoGenericWithLoc(const Twine &MsgStr, const Function &Fn, const DiagnosticLocation &Loc, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoGeneric(const Instruction *I, const Twine &ErrMsg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
DiagnosticInfoGeneric(const Twine &MsgStr LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
const Twine & getMsgStr() const
const Instruction * getInstruction() const
Common features for diagnostics dealing with optimization remarks that are used by IR passes.
DiagnosticInfoIROptimization(const char *PassName, StringRef Prepend, const DiagnosticInfoIROptimization &Orig)
This is ctor variant allows a pass to build an optimization remark from an existing remark.
DiagnosticInfoIROptimization(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, StringRef RemarkName, const Function &Fn, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion=nullptr)
PassName is the name of the pass emitting this diagnostic.
DiagnosticInfoIROptimization(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface.
const BasicBlock * getCodeRegion() const
static bool classof(const DiagnosticInfo *DI)
static bool classof(const DiagnosticInfo *DI)
const Function & getFunction() const
DiagnosticInfoISelFallback(const Function &Fn, DiagnosticSeverity Severity=DS_Warning)
DiagnosticInfoIgnoringInvalidDebugMetadata(const Module &M, DiagnosticSeverity Severity=DS_Warning)
The module that is concerned by this debug metadata version diagnostic.
static bool classof(const DiagnosticInfo *DI)
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoInlineAsm(const Instruction &I, const Twine &MsgStr LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
Instr gives the original instruction that triggered the diagnostic.
const Instruction * getInstruction() const
DiagnosticInfoInlineAsm(uint64_t LocCookie, const Twine &MsgStr LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
LocCookie if non-zero gives the line number for this report.
const Twine & getMsgStr() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoInstrumentation(const Twine &DiagMsg, DiagnosticSeverity Severity=DS_Warning)
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoLegalizationFailure(const Twine &MsgStr LLVM_LIFETIME_BOUND, const Function &Fn, const DiagnosticLocation &Loc, DiagnosticSeverity Severity=DS_Error)
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoMIRParser(DiagnosticSeverity Severity, const SMDiagnostic &Diagnostic)
const SMDiagnostic & getDiagnostic() const
const Twine & getMsg() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg LLVM_LIFETIME_BOUND)
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
ArrayRef< Argument > getArgs() const
int FirstExtraArgIndex
If positive, the index of the first argument that only appear in the optimization records and not in ...
const char * PassName
Name of the pass that triggers this report.
StringRef RemarkName
Textual identifier for the remark (single-word, CamelCase).
bool IsVerbose
The remark is expected to be noisy.
std::optional< uint64_t > Hotness
If profile information is available, this is the number of times the corresponding code was executed ...
SmallVector< Argument, 4 > Args
Arguments collected via the streaming interface.
void setHotness(std::optional< uint64_t > H)
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoOptimizationBase(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, StringRef RemarkName, const Function &Fn, const DiagnosticLocation &Loc)
PassName is the name of the pass emitting this diagnostic.
virtual bool isEnabled() const =0
Return true if this optimization remark is enabled by one of of the LLVM command line flags (-pass-re...
std::optional< uint64_t > getHotness() const
Diagnostic information for optimization failures.
DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Fn is the function where the diagnostic is being emitted.
static bool classof(const DiagnosticInfo *DI)
const char * getFileName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
const Twine & getMsg() const
DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn, const DiagnosticLocation &DL, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
static bool classof(const DiagnosticInfo *DI)
const Function & getFunction() const
const char * getResourceName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName, uint64_t ResourceSize, uint64_t ResourceLimit, DiagnosticSeverity Severity=DS_Warning, DiagnosticKind Kind=DK_ResourceLimit)
The function that is concerned by this stack size diagnostic.
DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoSampleProfile(const Twine &Msg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum, const Twine &Msg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
static bool classof(const DiagnosticInfo *DI)
const SMDiagnostic & getSMDiag() const
DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName, bool InlineAsmDiag=true, uint64_t LocCookie=0)
StringRef getModuleName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize, uint64_t StackLimit, DiagnosticSeverity Severity=DS_Warning)
const Twine & getMessage() const
DiagnosticInfoUnsupported(const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND, const DiagnosticLocation &Loc=DiagnosticLocation(), DiagnosticSeverity Severity=DS_Error)
Fn is the function where the diagnostic is being emitted.
static bool classof(const DiagnosticInfo *DI)
bool isLocationAvailable() const
Return true if location information is available for this diagnostic.
const Function & getFunction() const
DiagnosticLocation getLocation() const
DiagnosticInfoWithLocationBase(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const Function &Fn, const DiagnosticLocation &Loc)
Fn is the function where the diagnostic is being emitted.
void getLocation(StringRef &RelativePath, unsigned &Line, unsigned &Column) const
Return location information for this diagnostic in three parts: the relative source file path,...
This is the base abstract class for diagnostic reporting in the backend.
DiagnosticSeverity getSeverity() const
DiagnosticInfo(int Kind, DiagnosticSeverity Severity)
virtual ~DiagnosticInfo()=default
virtual void print(DiagnosticPrinter &DP) const =0
Print using the given DP a user-friendly message.
LLVM_ABI std::string getAbsolutePath() const
Return the full path to the file.
LLVM_ABI StringRef getRelativePath() const
Return the file name relative to the compilation directory.
unsigned getColumn() const
Interface for custom diagnostic printing.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Diagnostic information for optimization analysis remarks related to pointer aliasing.
OptimizationRemarkAnalysisAliasing(const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
PassName is the name of the pass emitting this diagnostic.
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for optimization analysis remarks related to floating-point non-commutativity.
OptimizationRemarkAnalysisFPCommute(const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
PassName is the name of the pass emitting this diagnostic.
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for optimization analysis remarks.
OptimizationRemarkAnalysis(const char *PassName, StringRef Prepend, const OptimizationRemarkAnalysis &Orig)
This is ctor variant allows a pass to build an optimization remark from an existing remark.
OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
PassName is the name of the pass emitting this diagnostic.
OptimizationRemarkAnalysis(enum DiagnosticKind Kind, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for missed-optimization remarks.
static bool classof(const DiagnosticInfo *DI)
OptimizationRemarkMissed(const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
PassName is the name of the pass emitting this diagnostic.
Diagnostic information for applied optimization remarks.
static bool classof(const DiagnosticInfo *DI)
OptimizationRemark(const char *PassName, StringRef RemarkName, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion)
PassName is the name of the pass emitting this diagnostic.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:282
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition Twine.cpp:17
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
LLVM Value Representation.
Definition Value.h:75
struct LLVMOpaqueDiagnosticInfo * LLVMDiagnosticInfoRef
Definition Types.h:150
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
std::function< void(const DiagnosticInfo &)> DiagnosticHandlerFunction
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition STLExtras.h:2138
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_DebugMetadataInvalid
@ DK_Instrumentation
@ DK_OptimizationRemarkAnalysis
@ DK_LastMachineRemark
@ DK_OptimizationRemarkAnalysisAliasing
@ DK_StackSize
@ DK_SampleProfile
@ DK_MachineOptimizationRemark
@ DK_Unsupported
@ DK_LastRemark
@ DK_OptimizationRemarkMissed
@ DK_MIRParser
@ DK_GenericWithLoc
@ DK_ResourceLimit
@ DK_MachineOptimizationRemarkAnalysis
@ DK_ISelFallback
@ DK_Lowering
@ DK_OptimizationRemark
@ DK_FirstMachineRemark
@ DK_DontCall
@ DK_MachineOptimizationRemarkMissed
@ DK_PGOProfile
@ DK_InlineAsm
@ DK_DebugMetadataVersion
@ DK_OptimizationFailure
@ DK_FirstRemark
@ DK_MisExpect
@ DK_LegalizationFailure
@ DK_OptimizationRemarkAnalysisFPCommute
@ DK_FirstPluginKind
@ DK_RegAllocFailure
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
static DiagnosticSeverity getDiagnosticSeverity(SourceMgr::DiagKind DK)
#define N
Used in the streaming interface as the general argument type.
When an instance of this is inserted into the stream, the arguments following will not appear in the ...
Used to set IsVerbose via the stream interface.