LLVM 24.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 <cstdint>
30#include <functional>
31#include <optional>
32#include <string>
33#include <utility>
34
35namespace llvm {
36
37// Forward declarations.
39class DIFile;
40class DISubprogram;
41class CallInst;
42class Function;
43class Instruction;
44class InstructionCost;
45class Module;
46class Type;
47class Value;
48
49/// Defines the different supported severity of a diagnostic.
50enum DiagnosticSeverity : char {
54 // A note attaches additional information to one of the previous diagnostic
55 // types.
57};
58
59/// Defines the different supported kind of a diagnostic.
60/// This enum should be extended with a new ID for each added concrete subclass.
99
100/// Get the next available kind ID for a plugin diagnostic.
101/// Each time this function is called, it returns a different number.
102/// Therefore, a plugin that wants to "identify" its own classes
103/// with a dynamic identifier, just have to use this method to get a new ID
104/// and assign it to each of its classes.
105/// The returned ID will be greater than or equal to DK_FirstPluginKind.
106/// Thus, the plugin identifiers will not conflict with the
107/// DiagnosticKind values.
109
110/// This is the base abstract class for diagnostic reporting in
111/// the backend.
112/// The print method must be overloaded by the subclasses to print a
113/// user-friendly message in the client of the backend (let us call it a
114/// frontend).
116private:
117 /// Kind defines the kind of report this is about.
118 const /* DiagnosticKind */ int Kind;
119 /// Severity gives the severity of the diagnostic.
120 const DiagnosticSeverity Severity;
121
122 virtual void anchor();
123public:
124 DiagnosticInfo(/* DiagnosticKind */ int Kind, DiagnosticSeverity Severity)
125 : Kind(Kind), Severity(Severity) {}
126
127 virtual ~DiagnosticInfo() = default;
128
129 /* DiagnosticKind */ int getKind() const { return Kind; }
130 DiagnosticSeverity getSeverity() const { return Severity; }
131
132 /// Print using the given \p DP a user-friendly message.
133 /// This is the default message that will be printed to the user.
134 /// It is used when the frontend does not directly take advantage
135 /// of the information contained in fields of the subclasses.
136 /// The printed message must not end with '.' nor start with a severity
137 /// keyword.
138 virtual void print(DiagnosticPrinter &DP) const = 0;
139};
140
141using DiagnosticHandlerFunction = std::function<void(const DiagnosticInfo &)>;
142
144 const Twine &MsgStr;
145 const Instruction *Inst = nullptr;
146
147public:
148 /// \p MsgStr is the message to be reported to the frontend.
149 /// This class does not copy \p MsgStr, therefore the reference must be valid
150 /// for the whole life time of the Diagnostic.
152 DiagnosticSeverity Severity = DS_Error)
153 : DiagnosticInfo(DK_Generic, Severity), MsgStr(MsgStr) {}
154
156 const Twine &ErrMsg LLVM_LIFETIME_BOUND,
157 DiagnosticSeverity Severity = DS_Error)
158 : DiagnosticInfo(DK_Generic, Severity), MsgStr(ErrMsg), Inst(I) {}
159
160 const Twine &getMsgStr() const { return MsgStr; }
161 const Instruction *getInstruction() const { return Inst; }
162
163 /// \see DiagnosticInfo::print.
164 void print(DiagnosticPrinter &DP) const override;
165
166 static bool classof(const DiagnosticInfo *DI) {
167 return DI->getKind() == DK_Generic;
168 }
169};
170
171/// Diagnostic information for inline asm reporting.
172/// This is basically a message and an optional location.
174private:
175 /// Optional line information. 0 if not set.
176 uint64_t LocCookie = 0;
177 /// Message to be reported.
178 const Twine &MsgStr;
179 /// Optional origin of the problem.
180 const Instruction *Instr = nullptr;
181
182public:
183 /// \p LocCookie if non-zero gives the line number for this report.
184 /// \p MsgStr gives the message.
185 /// This class does not copy \p MsgStr, therefore the reference must be valid
186 /// for the whole life time of the Diagnostic.
188 const Twine &MsgStr LLVM_LIFETIME_BOUND,
189 DiagnosticSeverity Severity = DS_Error);
190
191 /// \p Instr gives the original instruction that triggered the diagnostic.
192 /// \p MsgStr gives the message.
193 /// This class does not copy \p MsgStr, therefore the reference must be valid
194 /// for the whole life time of the Diagnostic.
195 /// Same for \p I.
197 const Twine &MsgStr LLVM_LIFETIME_BOUND,
198 DiagnosticSeverity Severity = DS_Error);
199
200 uint64_t getLocCookie() const { return LocCookie; }
201 const Twine &getMsgStr() const { return MsgStr; }
202 const Instruction *getInstruction() const { return Instr; }
203
204 /// \see DiagnosticInfo::print.
205 void print(DiagnosticPrinter &DP) const override;
206
207 static bool classof(const DiagnosticInfo *DI) {
208 return DI->getKind() == DK_InlineAsm;
209 }
210};
211
212/// Diagnostic information for debug metadata version reporting.
213/// This is basically a module and a version.
215private:
216 /// The module that is concerned by this debug metadata version diagnostic.
217 const Module &M;
218 /// The actual metadata version.
219 unsigned MetadataVersion;
220
221public:
222 /// \p The module that is concerned by this debug metadata version diagnostic.
223 /// \p The actual metadata version.
224 DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion,
226 : DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M),
227 MetadataVersion(MetadataVersion) {}
228
229 const Module &getModule() const { return M; }
230 unsigned getMetadataVersion() const { return MetadataVersion; }
231
232 /// \see DiagnosticInfo::print.
233 void print(DiagnosticPrinter &DP) const override;
234
235 static bool classof(const DiagnosticInfo *DI) {
236 return DI->getKind() == DK_DebugMetadataVersion;
237 }
238};
239
240/// Diagnostic information for stripping invalid debug metadata.
242 : public DiagnosticInfo {
243private:
244 /// The module that is concerned by this invalid debug metadata diagnostic.
245 const Module &M;
246
247public:
248 /// \p The module that is concerned by this invalid debug metadata diagnostic.
252
253 const Module &getModule() const { return M; }
254
255 /// \see DiagnosticInfo::print.
256 void print(DiagnosticPrinter &DP) const override;
257
258 static bool classof(const DiagnosticInfo *DI) {
259 return DI->getKind() == DK_DebugMetadataInvalid;
260 }
261};
262
263/// Diagnostic information for the sample profiler.
265public:
266 DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
267 const Twine &Msg LLVM_LIFETIME_BOUND,
268 DiagnosticSeverity Severity = DS_Error)
269 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
270 LineNum(LineNum), Msg(Msg) {}
272 const Twine &Msg LLVM_LIFETIME_BOUND,
273 DiagnosticSeverity Severity = DS_Error)
274 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
275 Msg(Msg) {}
279
280 /// \see DiagnosticInfo::print.
281 void print(DiagnosticPrinter &DP) const override;
282
283 static bool classof(const DiagnosticInfo *DI) {
284 return DI->getKind() == DK_SampleProfile;
285 }
286
287 StringRef getFileName() const { return FileName; }
288 unsigned getLineNum() const { return LineNum; }
289 const Twine &getMsg() const { return Msg; }
290
291private:
292 /// Name of the input file associated with this diagnostic.
293 StringRef FileName;
294
295 /// Line number where the diagnostic occurred. If 0, no line number will
296 /// be emitted in the message.
297 unsigned LineNum = 0;
298
299 /// Message to report.
300 const Twine &Msg;
301};
302
303/// Diagnostic information for the PGO profiler.
305public:
306 DiagnosticInfoPGOProfile(const char *FileName,
307 const Twine &Msg LLVM_LIFETIME_BOUND,
308 DiagnosticSeverity Severity = DS_Error)
309 : DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
310
311 /// \see DiagnosticInfo::print.
312 void print(DiagnosticPrinter &DP) const override;
313
314 static bool classof(const DiagnosticInfo *DI) {
315 return DI->getKind() == DK_PGOProfile;
316 }
317
318 const char *getFileName() const { return FileName; }
319 const Twine &getMsg() const { return Msg; }
320
321private:
322 /// Name of the input file associated with this diagnostic.
323 const char *FileName;
324
325 /// Message to report.
326 const Twine &Msg;
327};
328
330 DIFile *File = nullptr;
331 unsigned Line = 0;
332 unsigned Column = 0;
333
334public:
338
339 bool isValid() const { return File; }
340 const DIFile *getFile() 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 Twine &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.
486 const Twine &ResourceName LLVM_LIFETIME_BOUND,
487 uint64_t ResourceSize, uint64_t ResourceLimit,
490
491 const Function &getFunction() const { return Fn; }
492 const Twine &getResourceName() const { return ResourceName; }
493 uint64_t getResourceSize() const { return ResourceSize; }
494 uint64_t getResourceLimit() const { return ResourceLimit; }
495
496 /// \see DiagnosticInfo::print.
497 void print(DiagnosticPrinter &DP) const override;
498
499 static bool classof(const DiagnosticInfo *DI) {
500 return DI->getKind() == DK_ResourceLimit || DI->getKind() == DK_StackSize;
501 }
502};
503
505 void anchor() override;
506 const Twine ResourceNameStr{"stack frame size"};
507
508public:
510 uint64_t StackLimit,
512 : DiagnosticInfoResourceLimit(Fn, ResourceNameStr, StackSize, StackLimit,
513 Severity, DK_StackSize) {}
514
517
518 static bool classof(const DiagnosticInfo *DI) {
519 return DI->getKind() == DK_StackSize;
520 }
521};
522
523/// Common features for diagnostics dealing with optimization remarks
524/// that are used by both IR and MIR passes.
527public:
528 /// Used to set IsVerbose via the stream interface.
529 struct setIsVerbose {};
530
531 /// When an instance of this is inserted into the stream, the arguments
532 /// following will not appear in the remark printed in the compiler output
533 /// (-Rpass) but only in the optimization record file
534 /// (-fsave-optimization-record).
535 struct setExtraArgs {};
536
537 /// Used in the streaming interface as the general argument type. It
538 /// internally converts everything into a key-value pair.
539 struct Argument {
540 std::string Key;
541 std::string Val;
542 // If set, the debug location corresponding to the value.
544
545 explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
549 Argument(StringRef Key, const char *S) : Argument(Key, StringRef(S)) {};
553 LLVM_ABI Argument(StringRef Key, long long N);
554 LLVM_ABI Argument(StringRef Key, unsigned N);
555 LLVM_ABI Argument(StringRef Key, unsigned long N);
556 LLVM_ABI Argument(StringRef Key, unsigned long long N);
558 Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
562 };
563
564 /// \p PassName is the name of the pass emitting this diagnostic. \p
565 /// RemarkName is a textual identifier for the remark (single-word,
566 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
567 /// \p Loc is the location information to use in the diagnostic. If line table
568 /// information is available, the diagnostic will include the source code
569 /// location.
571 enum DiagnosticSeverity Severity,
572 const char *PassName, StringRef RemarkName,
573 const Function &Fn,
574 const DiagnosticLocation &Loc)
575 : DiagnosticInfoWithLocationBase(Kind, Severity, Fn, Loc),
577
578 void insert(StringRef S);
579 void insert(Argument A);
580 void insert(setIsVerbose V);
581 void insert(setExtraArgs EA);
582
583 /// \see DiagnosticInfo::print.
584 void print(DiagnosticPrinter &DP) const override;
585
586 /// Return true if this optimization remark is enabled by one of
587 /// of the LLVM command line flags (-pass-remarks, -pass-remarks-missed,
588 /// or -pass-remarks-analysis). Note that this only handles the LLVM
589 /// flags. We cannot access Clang flags from here (they are handled
590 /// in BackendConsumer::OptimizationRemarkHandler).
591 virtual bool isEnabled() const = 0;
592
593 StringRef getPassName() const { return PassName; }
595 std::string getMsg() const;
596 std::optional<uint64_t> getHotness() const { return Hotness; }
597 void setHotness(std::optional<uint64_t> H) { Hotness = H; }
598
599 bool isVerbose() const { return IsVerbose; }
600
601 ArrayRef<Argument> getArgs() const { return Args; }
602
603 static bool classof(const DiagnosticInfo *DI) {
604 return (DI->getKind() >= DK_FirstRemark &&
605 DI->getKind() <= DK_LastRemark) ||
606 (DI->getKind() >= DK_FirstMachineRemark &&
608 }
609
610 bool isPassed() const {
611 return (getKind() == DK_OptimizationRemark ||
613 }
614
615 bool isMissed() const {
618 }
619
624
625protected:
626 /// Name of the pass that triggers this report. If this matches the
627 /// regular expression given in -Rpass=regexp, then the remark will
628 /// be emitted.
629 const char *PassName;
630
631 /// Textual identifier for the remark (single-word, CamelCase). Can be used
632 /// by external tools reading the output file for optimization remarks to
633 /// identify the remark.
635
636 /// If profile information is available, this is the number of times the
637 /// corresponding code was executed in a profile instrumentation run.
638 std::optional<uint64_t> Hotness;
639
640 /// Arguments collected via the streaming interface.
642
643 /// The remark is expected to be noisy.
644 bool IsVerbose = false;
645
646 /// If positive, the index of the first argument that only appear in
647 /// the optimization records and not in the remark printed in the compiler
648 /// output.
650};
651
652/// Allow the insertion operator to return the actual remark type rather than a
653/// common base class. This allows returning the result of the insertion
654/// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah".
655template <class RemarkT>
656decltype(auto)
657operator<<(RemarkT &&R,
658 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
659 std::remove_reference_t<RemarkT>>,
660 StringRef>
661 S) {
662 R.insert(S);
663 return std::forward<RemarkT>(R);
664}
665
666template <class RemarkT>
667decltype(auto)
668operator<<(RemarkT &&R,
669 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
670 std::remove_reference_t<RemarkT>>,
672 A) {
673 R.insert(A);
674 return std::forward<RemarkT>(R);
675}
676
677template <class RemarkT>
678decltype(auto)
679operator<<(RemarkT &&R,
680 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
681 std::remove_reference_t<RemarkT>>,
683 V) {
684 R.insert(V);
685 return std::forward<RemarkT>(R);
686}
687
688template <class RemarkT>
689decltype(auto)
690operator<<(RemarkT &&R,
691 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
692 std::remove_reference_t<RemarkT>>,
694 EA) {
695 R.insert(EA);
696 return std::forward<RemarkT>(R);
697}
698
699/// Common features for diagnostics dealing with optimization remarks
700/// that are used by IR passes.
703 void anchor() override;
704public:
705 /// \p PassName is the name of the pass emitting this diagnostic. \p
706 /// RemarkName is a textual identifier for the remark (single-word,
707 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
708 /// \p Loc is the location information to use in the diagnostic. If line table
709 /// information is available, the diagnostic will include the source code
710 /// location. \p CodeRegion is IR value that the optimization operates on.
711 /// This is currently used to provide run-time hotness information with PGO.
713 enum DiagnosticSeverity Severity,
714 const char *PassName, StringRef RemarkName,
715 const Function &Fn,
716 const DiagnosticLocation &Loc,
717 const BasicBlock *CodeRegion = nullptr)
719 Loc),
720 CodeRegion(CodeRegion) {}
721
722 /// This is ctor variant allows a pass to build an optimization remark
723 /// from an existing remark.
724 ///
725 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
726 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
727 /// remark. The string \p Prepend will be emitted before the original
728 /// message.
733 Orig.RemarkName, Orig.getFunction(), Orig.getLocation()),
734 CodeRegion(Orig.getCodeRegion()) {
735 *this << Prepend;
737 }
738
739 /// Legacy interface.
740 /// \p PassName is the name of the pass emitting this diagnostic.
741 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
742 /// the location information to use in the diagnostic. If line table
743 /// information is available, the diagnostic will include the source code
744 /// location. \p Msg is the message to show. Note that this class does not
745 /// copy this message, so this reference must be valid for the whole life time
746 /// of the diagnostic.
748 enum DiagnosticSeverity Severity,
749 const char *PassName, const Function &Fn,
750 const DiagnosticLocation &Loc, const Twine &Msg)
751 : DiagnosticInfoOptimizationBase(Kind, Severity, PassName, "", Fn, Loc) {
752 *this << Msg.str();
753 }
754
755 const BasicBlock *getCodeRegion() const { return CodeRegion; }
756
757 static bool classof(const DiagnosticInfo *DI) {
758 return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
759 }
760
761private:
762 /// The IR region (currently basic block) that the optimization operates on.
763 /// This is currently used to provide run-time hotness information with PGO.
764 const BasicBlock *CodeRegion = nullptr;
765};
766
767/// Diagnostic information for applied optimization remarks.
769public:
770 /// \p PassName is the name of the pass emitting this diagnostic. If this name
771 /// matches the regular expression given in -Rpass=, then the diagnostic will
772 /// be emitted. \p RemarkName is a textual identifier for the remark (single-
773 /// word, CamelCase). \p Loc is the debug location and \p CodeRegion is the
774 /// region that the optimization operates on.
776 const DiagnosticLocation &Loc,
777 const BasicBlock *CodeRegion);
778
779 /// Same as above, but the debug location and code region are derived from \p
780 /// Instr.
782 const Instruction *Inst);
783
784 /// Same as above, but the debug location and code region are derived from \p
785 /// Func.
787 const Function *Func);
788
789 static bool classof(const DiagnosticInfo *DI) {
790 return DI->getKind() == DK_OptimizationRemark;
791 }
792
793 /// \see DiagnosticInfoOptimizationBase::isEnabled.
794 bool isEnabled() const override;
795
796private:
797 /// This is deprecated now and only used by the function API below.
798 /// \p PassName is the name of the pass emitting this diagnostic. If
799 /// this name matches the regular expression given in -Rpass=, then the
800 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
801 /// is being emitted. \p Loc is the location information to use in the
802 /// diagnostic. If line table information is available, the diagnostic
803 /// will include the source code location. \p Msg is the message to show.
804 /// Note that this class does not copy this message, so this reference
805 /// must be valid for the whole life time of the diagnostic.
806 OptimizationRemark(const char *PassName, const Function &Fn,
807 const DiagnosticLocation &Loc, const Twine &Msg)
809 Fn, Loc, Msg) {}
810};
811
812/// Diagnostic information for missed-optimization remarks.
814public:
815 /// \p PassName is the name of the pass emitting this diagnostic. If this name
816 /// matches the regular expression given in -Rpass-missed=, then the
817 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
818 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
819 /// CodeRegion is the region that the optimization operates on.
821 const DiagnosticLocation &Loc,
822 const BasicBlock *CodeRegion);
823
824 /// Same as above but \p Inst is used to derive code region and debug
825 /// location.
827 const Instruction *Inst);
828
829 /// Same as above but \p F is used to derive code region and debug
830 /// location.
832 const Function *F);
833
834 static bool classof(const DiagnosticInfo *DI) {
835 return DI->getKind() == DK_OptimizationRemarkMissed;
836 }
837
838 /// \see DiagnosticInfoOptimizationBase::isEnabled.
839 bool isEnabled() const override;
840
841private:
842 /// This is deprecated now and only used by the function API below.
843 /// \p PassName is the name of the pass emitting this diagnostic. If
844 /// this name matches the regular expression given in -Rpass-missed=, then the
845 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
846 /// is being emitted. \p Loc is the location information to use in the
847 /// diagnostic. If line table information is available, the diagnostic
848 /// will include the source code location. \p Msg is the message to show.
849 /// Note that this class does not copy this message, so this reference
850 /// must be valid for the whole life time of the diagnostic.
851 OptimizationRemarkMissed(const char *PassName, const Function &Fn,
852 const DiagnosticLocation &Loc, const Twine &Msg)
854 PassName, Fn, Loc, Msg) {}
855};
856
857/// Diagnostic information for optimization analysis remarks.
860public:
861 /// \p PassName is the name of the pass emitting this diagnostic. If this name
862 /// matches the regular expression given in -Rpass-analysis=, then the
863 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
864 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
865 /// CodeRegion is the region that the optimization operates on.
867 const DiagnosticLocation &Loc,
868 const BasicBlock *CodeRegion);
869
870 /// This is ctor variant allows a pass to build an optimization remark
871 /// from an existing remark.
872 ///
873 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
874 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
875 /// remark. The string \p Prepend will be emitted before the original
876 /// message.
880
881 /// Same as above but \p Inst is used to derive code region and debug
882 /// location.
883 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
884 const Instruction *Inst);
885
886 /// Same as above but \p F is used to derive code region and debug
887 /// location.
888 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
889 const Function *F);
890
891 static bool classof(const DiagnosticInfo *DI) {
893 }
894
895 /// \see DiagnosticInfoOptimizationBase::isEnabled.
896 bool isEnabled() const override;
897
898 static const char *AlwaysPrint;
899
900 bool shouldAlwaysPrint() const { return getPassName() == AlwaysPrint; }
901
902protected:
904 const Function &Fn, const DiagnosticLocation &Loc,
905 const Twine &Msg)
907
909 StringRef RemarkName,
910 const DiagnosticLocation &Loc,
911 const BasicBlock *CodeRegion);
912
913private:
914 /// This is deprecated now and only used by the function API below.
915 /// \p PassName is the name of the pass emitting this diagnostic. If
916 /// this name matches the regular expression given in -Rpass-analysis=, then
917 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
918 /// is being emitted. \p Loc is the location information to use in the
919 /// diagnostic. If line table information is available, the diagnostic will
920 /// include the source code location. \p Msg is the message to show. Note that
921 /// this class does not copy this message, so this reference must be valid for
922 /// the whole life time of the diagnostic.
923 OptimizationRemarkAnalysis(const char *PassName, const Function &Fn,
924 const DiagnosticLocation &Loc, const Twine &Msg)
926 PassName, Fn, Loc, Msg) {}
927};
928
929/// Diagnostic information for optimization analysis remarks related to
930/// floating-point non-commutativity.
933 void anchor() override;
934public:
935 /// \p PassName is the name of the pass emitting this diagnostic. If this name
936 /// matches the regular expression given in -Rpass-analysis=, then the
937 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
938 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
939 /// CodeRegion is the region that the optimization operates on. The front-end
940 /// will append its own message related to options that address floating-point
941 /// non-commutativity.
948
949 static bool classof(const DiagnosticInfo *DI) {
951 }
952
953private:
954 /// This is deprecated now and only used by the function API below.
955 /// \p PassName is the name of the pass emitting this diagnostic. If
956 /// this name matches the regular expression given in -Rpass-analysis=, then
957 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
958 /// is being emitted. \p Loc is the location information to use in the
959 /// diagnostic. If line table information is available, the diagnostic will
960 /// include the source code location. \p Msg is the message to show. The
961 /// front-end will append its own message related to options that address
962 /// floating-point non-commutativity. Note that this class does not copy this
963 /// message, so this reference must be valid for the whole life time of the
964 /// diagnostic.
966 const DiagnosticLocation &Loc,
967 const Twine &Msg)
969 PassName, Fn, Loc, Msg) {}
970};
971
972/// Diagnostic information for optimization analysis remarks related to
973/// pointer aliasing.
976 void anchor() override;
977public:
978 /// \p PassName is the name of the pass emitting this diagnostic. If this name
979 /// matches the regular expression given in -Rpass-analysis=, then the
980 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
981 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
982 /// CodeRegion is the region that the optimization operates on. The front-end
983 /// will append its own message related to options that address pointer
984 /// aliasing legality.
990
991 static bool classof(const DiagnosticInfo *DI) {
993 }
994
995private:
996 /// This is deprecated now and only used by the function API below.
997 /// \p PassName is the name of the pass emitting this diagnostic. If
998 /// this name matches the regular expression given in -Rpass-analysis=, then
999 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
1000 /// is being emitted. \p Loc is the location information to use in the
1001 /// diagnostic. If line table information is available, the diagnostic will
1002 /// include the source code location. \p Msg is the message to show. The
1003 /// front-end will append its own message related to options that address
1004 /// pointer aliasing legality. Note that this class does not copy this
1005 /// message, so this reference must be valid for the whole life time of the
1006 /// diagnostic.
1008 const DiagnosticLocation &Loc,
1009 const Twine &Msg)
1011 PassName, Fn, Loc, Msg) {}
1012};
1013
1014/// Diagnostic information for machine IR parser.
1015// FIXME: Remove this, use DiagnosticInfoSrcMgr instead.
1017 const SMDiagnostic &Diagnostic;
1018
1019public:
1021 const SMDiagnostic &Diagnostic)
1022 : DiagnosticInfo(DK_MIRParser, Severity), Diagnostic(Diagnostic) {}
1023
1024 const SMDiagnostic &getDiagnostic() const { return Diagnostic; }
1025
1026 void print(DiagnosticPrinter &DP) const override;
1027
1028 static bool classof(const DiagnosticInfo *DI) {
1029 return DI->getKind() == DK_MIRParser;
1030 }
1031};
1032
1033/// Diagnostic information for IR instrumentation reporting.
1035 const Twine &Msg;
1036
1037public:
1039 DiagnosticSeverity Severity = DS_Warning)
1040 : DiagnosticInfo(DK_Instrumentation, Severity), Msg(DiagMsg) {}
1041
1042 void print(DiagnosticPrinter &DP) const override;
1043
1044 static bool classof(const DiagnosticInfo *DI) {
1045 return DI->getKind() == DK_Instrumentation;
1046 }
1047};
1048
1049/// Diagnostic information for ISel fallback path.
1051 /// The function that is concerned by this diagnostic.
1052 const Function &Fn;
1053
1054public:
1056 DiagnosticSeverity Severity = DS_Warning)
1057 : DiagnosticInfo(DK_ISelFallback, Severity), Fn(Fn) {}
1058
1059 const Function &getFunction() const { return Fn; }
1060
1061 void print(DiagnosticPrinter &DP) const override;
1062
1063 static bool classof(const DiagnosticInfo *DI) {
1064 return DI->getKind() == DK_ISelFallback;
1065 }
1066};
1067
1068// Create wrappers for C Binding types (see CBindingWrapping.h).
1070
1071/// Diagnostic information for optimization failures.
1074public:
1075 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1076 /// the location information to use in the diagnostic. If line table
1077 /// information is available, the diagnostic will include the source code
1078 /// location. \p Msg is the message to show. Note that this class does not
1079 /// copy this message, so this reference must be valid for the whole life time
1080 /// of the diagnostic.
1086
1087 /// \p PassName is the name of the pass emitting this diagnostic. \p
1088 /// RemarkName is a textual identifier for the remark (single-word,
1089 /// CamelCase). \p Loc is the debug location and \p CodeRegion is the
1090 /// region that the optimization operates on.
1092 const DiagnosticLocation &Loc,
1093 const BasicBlock *CodeRegion);
1094
1095 static bool classof(const DiagnosticInfo *DI) {
1096 return DI->getKind() == DK_OptimizationFailure;
1097 }
1098
1099 /// \see DiagnosticInfoOptimizationBase::isEnabled.
1100 bool isEnabled() const override;
1101};
1102
1103/// Diagnostic information for unsupported feature in backend.
1106private:
1107 const Twine &Msg;
1108
1109public:
1110 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1111 /// the location information to use in the diagnostic. If line table
1112 /// information is available, the diagnostic will include the source code
1113 /// location. \p Msg is the message to show. Note that this class does not
1114 /// copy this message, so this reference must be valid for the whole life time
1115 /// of the diagnostic.
1117 const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
1119 DiagnosticSeverity Severity = DS_Error)
1120 : DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
1121 Msg(Msg) {}
1122
1123 static bool classof(const DiagnosticInfo *DI) {
1124 return DI->getKind() == DK_Unsupported;
1125 }
1126
1127 const Twine &getMessage() const { return Msg; }
1128
1129 void print(DiagnosticPrinter &DP) const override;
1130};
1131
1132/// Diagnostic information for unsupported target intrinsics in backend.
1135private:
1136 unsigned IntrinsicID;
1137 StringRef RequiredFeatures;
1138
1139public:
1141 const Function &Fn, unsigned IntrinsicID,
1142 const DiagnosticLocation &Loc = DiagnosticLocation());
1143
1144 static bool classof(const DiagnosticInfo *DI) {
1145 return DI->getKind() == DK_UnsupportedTargetIntrinsic;
1146 }
1147
1148 unsigned getIntrinsicID() const { return IntrinsicID; }
1149 StringRef getRequiredFeatures() const { return RequiredFeatures; }
1150 std::string getMessage() const;
1151
1152 void print(DiagnosticPrinter &DP) const override;
1153};
1154
1155/// Diagnostic information for MisExpect analysis.
1157public:
1159 const Twine &Msg LLVM_LIFETIME_BOUND);
1160
1161 /// \see DiagnosticInfo::print.
1162 void print(DiagnosticPrinter &DP) const override;
1163
1164 static bool classof(const DiagnosticInfo *DI) {
1165 return DI->getKind() == DK_MisExpect;
1166 }
1167
1168 const Twine &getMsg() const { return Msg; }
1169
1170private:
1171 /// Message to report.
1172 const Twine &Msg;
1173};
1174
1176 switch (DK) {
1178 return DS_Error;
1179 break;
1181 return DS_Warning;
1182 break;
1184 return DS_Note;
1185 break;
1187 return DS_Remark;
1188 break;
1189 }
1190 llvm_unreachable("unknown SourceMgr::DiagKind");
1191}
1192
1193/// Diagnostic information for SMDiagnostic reporting.
1195 const SMDiagnostic &Diagnostic;
1196 StringRef ModName;
1197
1198 // For inlineasm !srcloc translation.
1199 bool InlineAsmDiag;
1200 uint64_t LocCookie;
1201
1202public:
1203 DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName,
1204 bool InlineAsmDiag = true, uint64_t LocCookie = 0)
1206 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1207 LocCookie(LocCookie) {}
1208
1209 StringRef getModuleName() const { return ModName; }
1210 bool isInlineAsmDiag() const { return InlineAsmDiag; }
1211 const SMDiagnostic &getSMDiag() const { return Diagnostic; }
1212 uint64_t getLocCookie() const { return LocCookie; }
1213 void print(DiagnosticPrinter &DP) const override;
1214
1215 static bool classof(const DiagnosticInfo *DI) {
1216 return DI->getKind() == DK_SrcMgr;
1217 }
1218};
1219
1220LLVM_ABI void diagnoseDontCall(const CallInst &CI);
1221
1222/// Inlining location extracted from debug info.
1230
1232 StringRef CalleeName;
1233 StringRef Note;
1234 uint64_t LocCookie;
1235 MDNode *InlinedFromMD = nullptr;
1236 SmallVector<DebugInlineInfo, 4> DebugInlineChain;
1237
1238public:
1240 DiagnosticSeverity DS, uint64_t LocCookie,
1241 MDNode *InlinedFromMD = nullptr)
1242 : DiagnosticInfo(DK_DontCall, DS), CalleeName(CalleeName), Note(Note),
1243 LocCookie(LocCookie), InlinedFromMD(InlinedFromMD) {}
1244
1245 StringRef getFunctionName() const { return CalleeName; }
1246 StringRef getNote() const { return Note; }
1247 uint64_t getLocCookie() const { return LocCookie; }
1248 MDNode *getInlinedFromMD() const { return InlinedFromMD; }
1249 SmallVector<std::pair<StringRef, uint64_t>> getInliningDecisions() const;
1250
1252 DebugInlineChain = std::move(Chain);
1253 }
1255 return DebugInlineChain;
1256 }
1257
1258 void print(DiagnosticPrinter &DP) const override;
1259 static bool classof(const DiagnosticInfo *DI) {
1260 return DI->getKind() == DK_DontCall;
1261 }
1262};
1263
1264} // end namespace llvm
1265
1266#endif // LLVM_IR_DIAGNOSTICINFO_H
uint64_t uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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:211
#define LLVM_LIFETIME_BOUND
Definition Compiler.h:464
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define H(x, y, z)
Definition MD5.cpp:56
#define T
#define P(N)
static llvm::Expected< std::string > getAbsolutePath(StringRef Authority, StringRef Body)
Definition Protocol.cpp:158
const char * Msg
This file defines the SmallVector class.
static const char PassName[]
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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:126
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, MDNode *InlinedFromMD=nullptr)
static bool classof(const DiagnosticInfo *DI)
void setDebugInlineChain(SmallVector< DebugInlineInfo, 4 > &&Chain)
StringRef getFunctionName() const
ArrayRef< DebugInlineInfo > getDebugInlineChain() 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 invalid debug metadata 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
static bool classof(const DiagnosticInfo *DI)
const Twine & getResourceName() const
DiagnosticInfoResourceLimit(const Function &Fn, const Twine &ResourceName LLVM_LIFETIME_BOUND, 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)
DiagnosticInfoUnsupportedTargetIntrinsic(const Function &Fn, unsigned IntrinsicID, const DiagnosticLocation &Loc=DiagnosticLocation())
static bool classof(const DiagnosticInfo *DI)
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.
const DIFile * getFile() const
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.
Metadata node.
Definition Metadata.h:1087
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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:307
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
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.
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:2224
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_DebugMetadataInvalid
@ DK_Instrumentation
@ DK_OptimizationRemarkAnalysis
@ DK_LastMachineRemark
@ DK_OptimizationRemarkAnalysisAliasing
@ DK_UnsupportedTargetIntrinsic
@ 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
Inlining location extracted from debug info.
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.