LLVM 23.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 /// Return the full path to the file.
341 LLVM_ABI std::string getAbsolutePath() const;
342 /// Return the file name relative to the compilation directory.
344 unsigned getLine() const { return Line; }
345 unsigned getColumn() const { return Column; }
346};
347
348/// Common features for diagnostics with an associated location.
350 void anchor() override;
351public:
352 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
353 /// the location information to use in the diagnostic.
355 enum DiagnosticSeverity Severity,
356 const Function &Fn,
357 const DiagnosticLocation &Loc)
358 : DiagnosticInfo(Kind, Severity), Fn(Fn), Loc(Loc) {}
359
360 /// Return true if location information is available for this diagnostic.
361 bool isLocationAvailable() const { return Loc.isValid(); }
362
363 /// Return a string with the location information for this diagnostic
364 /// in the format "file:line:col". If location information is not available,
365 /// it returns "<unknown>:0:0".
366 std::string getLocationStr() const;
367
368 /// Return location information for this diagnostic in three parts:
369 /// the relative source file path, line number and column.
370 void getLocation(StringRef &RelativePath, unsigned &Line,
371 unsigned &Column) const;
372
373 /// Return the absolute path tot the file.
374 std::string getAbsolutePath() const;
375
376 const Function &getFunction() const { return Fn; }
377 DiagnosticLocation getLocation() const { return Loc; }
378
379private:
380 /// Function where this diagnostic is triggered.
381 const Function &Fn;
382
383 /// Debug location where this diagnostic is triggered.
385};
386
389private:
390 /// Message to be reported.
391 const Twine &MsgStr;
392
393public:
395 const Function &Fn,
396 const DiagnosticLocation &Loc,
397 DiagnosticSeverity Severity = DS_Error)
399 Loc),
400 MsgStr(MsgStr) {}
401
402 const Twine &getMsgStr() const { return MsgStr; }
403
404 void print(DiagnosticPrinter &DP) const override;
405
406 static bool classof(const DiagnosticInfo *DI) {
407 return DI->getKind() == DK_LegalizationFailure;
408 }
409};
410
413private:
414 /// Message to be reported.
415 const Twine &MsgStr;
416
417public:
418 /// \p MsgStr is the message to be reported to the frontend.
419 /// This class does not copy \p MsgStr, therefore the reference must be valid
420 /// for the whole life time of the Diagnostic.
422 const DiagnosticLocation &Loc,
423 DiagnosticSeverity Severity = DS_Error)
425 MsgStr(MsgStr) {}
426
427 const Twine &getMsgStr() const { return MsgStr; }
428
429 /// \see DiagnosticInfo::print.
430 void print(DiagnosticPrinter &DP) const override;
431
432 static bool classof(const DiagnosticInfo *DI) {
433 return DI->getKind() == DK_GenericWithLoc;
434 }
435};
436
439private:
440 /// Message to be reported.
441 const Twine &MsgStr;
442
443public:
444 /// \p MsgStr is the message to be reported to the frontend.
445 /// This class does not copy \p MsgStr, therefore the reference must be valid
446 /// for the whole life time of the Diagnostic.
447 DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn,
448 const DiagnosticLocation &DL,
449 DiagnosticSeverity Severity = DS_Error);
450
451 DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn,
452 DiagnosticSeverity Severity = DS_Error);
453
454 const Twine &getMsgStr() const { return MsgStr; }
455
456 /// \see DiagnosticInfo::print.
457 void print(DiagnosticPrinter &DP) const override;
458
459 static bool classof(const DiagnosticInfo *DI) {
460 return DI->getKind() == DK_RegAllocFailure;
461 }
462};
463
464/// Diagnostic information for stack size etc. reporting.
465/// This is basically a function and a size.
468private:
469 /// The function that is concerned by this resource limit diagnostic.
470 const Function &Fn;
471
472 /// Description of the resource type (e.g. stack size)
473 const Twine &ResourceName;
474
475 /// The computed size usage
476 uint64_t ResourceSize;
477
478 // Threshould passed
479 uint64_t ResourceLimit;
480
481public:
482 /// \p The function that is concerned by this stack size diagnostic.
483 /// \p The computed stack size.
485 const Twine &ResourceName LLVM_LIFETIME_BOUND,
486 uint64_t ResourceSize, uint64_t ResourceLimit,
489
490 const Function &getFunction() const { return Fn; }
491 const Twine &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 const Twine ResourceNameStr{"stack frame size"};
506
507public:
509 uint64_t StackLimit,
511 : DiagnosticInfoResourceLimit(Fn, ResourceNameStr, StackSize, StackLimit,
512 Severity, DK_StackSize) {}
513
516
517 static bool classof(const DiagnosticInfo *DI) {
518 return DI->getKind() == DK_StackSize;
519 }
520};
521
522/// Common features for diagnostics dealing with optimization remarks
523/// that are used by both IR and MIR passes.
526public:
527 /// Used to set IsVerbose via the stream interface.
528 struct setIsVerbose {};
529
530 /// When an instance of this is inserted into the stream, the arguments
531 /// following will not appear in the remark printed in the compiler output
532 /// (-Rpass) but only in the optimization record file
533 /// (-fsave-optimization-record).
534 struct setExtraArgs {};
535
536 /// Used in the streaming interface as the general argument type. It
537 /// internally converts everything into a key-value pair.
538 struct Argument {
539 std::string Key;
540 std::string Val;
541 // If set, the debug location corresponding to the value.
543
544 explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
548 Argument(StringRef Key, const char *S) : Argument(Key, StringRef(S)) {};
552 LLVM_ABI Argument(StringRef Key, long long N);
553 LLVM_ABI Argument(StringRef Key, unsigned N);
554 LLVM_ABI Argument(StringRef Key, unsigned long N);
555 LLVM_ABI Argument(StringRef Key, unsigned long long N);
557 Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
561 };
562
563 /// \p PassName is the name of the pass emitting this diagnostic. \p
564 /// RemarkName is a textual identifier for the remark (single-word,
565 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
566 /// \p Loc is the location information to use in the diagnostic. If line table
567 /// information is available, the diagnostic will include the source code
568 /// location.
570 enum DiagnosticSeverity Severity,
571 const char *PassName, StringRef RemarkName,
572 const Function &Fn,
573 const DiagnosticLocation &Loc)
574 : DiagnosticInfoWithLocationBase(Kind, Severity, Fn, Loc),
576
577 void insert(StringRef S);
578 void insert(Argument A);
579 void insert(setIsVerbose V);
580 void insert(setExtraArgs EA);
581
582 /// \see DiagnosticInfo::print.
583 void print(DiagnosticPrinter &DP) const override;
584
585 /// Return true if this optimization remark is enabled by one of
586 /// of the LLVM command line flags (-pass-remarks, -pass-remarks-missed,
587 /// or -pass-remarks-analysis). Note that this only handles the LLVM
588 /// flags. We cannot access Clang flags from here (they are handled
589 /// in BackendConsumer::OptimizationRemarkHandler).
590 virtual bool isEnabled() const = 0;
591
592 StringRef getPassName() const { return PassName; }
594 std::string getMsg() const;
595 std::optional<uint64_t> getHotness() const { return Hotness; }
596 void setHotness(std::optional<uint64_t> H) { Hotness = H; }
597
598 bool isVerbose() const { return IsVerbose; }
599
600 ArrayRef<Argument> getArgs() const { return Args; }
601
602 static bool classof(const DiagnosticInfo *DI) {
603 return (DI->getKind() >= DK_FirstRemark &&
604 DI->getKind() <= DK_LastRemark) ||
605 (DI->getKind() >= DK_FirstMachineRemark &&
607 }
608
609 bool isPassed() const {
610 return (getKind() == DK_OptimizationRemark ||
612 }
613
614 bool isMissed() const {
617 }
618
623
624protected:
625 /// Name of the pass that triggers this report. If this matches the
626 /// regular expression given in -Rpass=regexp, then the remark will
627 /// be emitted.
628 const char *PassName;
629
630 /// Textual identifier for the remark (single-word, CamelCase). Can be used
631 /// by external tools reading the output file for optimization remarks to
632 /// identify the remark.
634
635 /// If profile information is available, this is the number of times the
636 /// corresponding code was executed in a profile instrumentation run.
637 std::optional<uint64_t> Hotness;
638
639 /// Arguments collected via the streaming interface.
641
642 /// The remark is expected to be noisy.
643 bool IsVerbose = false;
644
645 /// If positive, the index of the first argument that only appear in
646 /// the optimization records and not in the remark printed in the compiler
647 /// output.
649};
650
651/// Allow the insertion operator to return the actual remark type rather than a
652/// common base class. This allows returning the result of the insertion
653/// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah".
654template <class RemarkT>
655decltype(auto)
656operator<<(RemarkT &&R,
657 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
658 std::remove_reference_t<RemarkT>>,
659 StringRef>
660 S) {
661 R.insert(S);
662 return std::forward<RemarkT>(R);
663}
664
665template <class RemarkT>
666decltype(auto)
667operator<<(RemarkT &&R,
668 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
669 std::remove_reference_t<RemarkT>>,
671 A) {
672 R.insert(A);
673 return std::forward<RemarkT>(R);
674}
675
676template <class RemarkT>
677decltype(auto)
678operator<<(RemarkT &&R,
679 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
680 std::remove_reference_t<RemarkT>>,
682 V) {
683 R.insert(V);
684 return std::forward<RemarkT>(R);
685}
686
687template <class RemarkT>
688decltype(auto)
689operator<<(RemarkT &&R,
690 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
691 std::remove_reference_t<RemarkT>>,
693 EA) {
694 R.insert(EA);
695 return std::forward<RemarkT>(R);
696}
697
698/// Common features for diagnostics dealing with optimization remarks
699/// that are used by IR passes.
702 void anchor() override;
703public:
704 /// \p PassName is the name of the pass emitting this diagnostic. \p
705 /// RemarkName is a textual identifier for the remark (single-word,
706 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
707 /// \p Loc is the location information to use in the diagnostic. If line table
708 /// information is available, the diagnostic will include the source code
709 /// location. \p CodeRegion is IR value that the optimization operates on.
710 /// This is currently used to provide run-time hotness information with PGO.
712 enum DiagnosticSeverity Severity,
713 const char *PassName, StringRef RemarkName,
714 const Function &Fn,
715 const DiagnosticLocation &Loc,
716 const BasicBlock *CodeRegion = nullptr)
718 Loc),
719 CodeRegion(CodeRegion) {}
720
721 /// This is ctor variant allows a pass to build an optimization remark
722 /// from an existing remark.
723 ///
724 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
725 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
726 /// remark. The string \p Prepend will be emitted before the original
727 /// message.
732 Orig.RemarkName, Orig.getFunction(), Orig.getLocation()),
733 CodeRegion(Orig.getCodeRegion()) {
734 *this << Prepend;
736 }
737
738 /// Legacy interface.
739 /// \p PassName is the name of the pass emitting this diagnostic.
740 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
741 /// the location information to use in the diagnostic. If line table
742 /// information is available, the diagnostic will include the source code
743 /// location. \p Msg is the message to show. Note that this class does not
744 /// copy this message, so this reference must be valid for the whole life time
745 /// of the diagnostic.
747 enum DiagnosticSeverity Severity,
748 const char *PassName, const Function &Fn,
749 const DiagnosticLocation &Loc, const Twine &Msg)
750 : DiagnosticInfoOptimizationBase(Kind, Severity, PassName, "", Fn, Loc) {
751 *this << Msg.str();
752 }
753
754 const BasicBlock *getCodeRegion() const { return CodeRegion; }
755
756 static bool classof(const DiagnosticInfo *DI) {
757 return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
758 }
759
760private:
761 /// The IR region (currently basic block) that the optimization operates on.
762 /// This is currently used to provide run-time hotness information with PGO.
763 const BasicBlock *CodeRegion = nullptr;
764};
765
766/// Diagnostic information for applied optimization remarks.
768public:
769 /// \p PassName is the name of the pass emitting this diagnostic. If this name
770 /// matches the regular expression given in -Rpass=, then the diagnostic will
771 /// be emitted. \p RemarkName is a textual identifier for the remark (single-
772 /// word, CamelCase). \p Loc is the debug location and \p CodeRegion is the
773 /// region that the optimization operates on.
775 const DiagnosticLocation &Loc,
776 const BasicBlock *CodeRegion);
777
778 /// Same as above, but the debug location and code region are derived from \p
779 /// Instr.
781 const Instruction *Inst);
782
783 /// Same as above, but the debug location and code region are derived from \p
784 /// Func.
786 const Function *Func);
787
788 static bool classof(const DiagnosticInfo *DI) {
789 return DI->getKind() == DK_OptimizationRemark;
790 }
791
792 /// \see DiagnosticInfoOptimizationBase::isEnabled.
793 bool isEnabled() const override;
794
795private:
796 /// This is deprecated now and only used by the function API below.
797 /// \p PassName is the name of the pass emitting this diagnostic. If
798 /// this name matches the regular expression given in -Rpass=, then the
799 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
800 /// is being emitted. \p Loc is the location information to use in the
801 /// diagnostic. If line table information is available, the diagnostic
802 /// will include the source code location. \p Msg is the message to show.
803 /// Note that this class does not copy this message, so this reference
804 /// must be valid for the whole life time of the diagnostic.
805 OptimizationRemark(const char *PassName, const Function &Fn,
806 const DiagnosticLocation &Loc, const Twine &Msg)
808 Fn, Loc, Msg) {}
809};
810
811/// Diagnostic information for missed-optimization remarks.
813public:
814 /// \p PassName is the name of the pass emitting this diagnostic. If this name
815 /// matches the regular expression given in -Rpass-missed=, then the
816 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
817 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
818 /// CodeRegion is the region that the optimization operates on.
820 const DiagnosticLocation &Loc,
821 const BasicBlock *CodeRegion);
822
823 /// Same as above but \p Inst is used to derive code region and debug
824 /// location.
826 const Instruction *Inst);
827
828 /// Same as above but \p F is used to derive code region and debug
829 /// location.
831 const Function *F);
832
833 static bool classof(const DiagnosticInfo *DI) {
834 return DI->getKind() == DK_OptimizationRemarkMissed;
835 }
836
837 /// \see DiagnosticInfoOptimizationBase::isEnabled.
838 bool isEnabled() const override;
839
840private:
841 /// This is deprecated now and only used by the function API below.
842 /// \p PassName is the name of the pass emitting this diagnostic. If
843 /// this name matches the regular expression given in -Rpass-missed=, then the
844 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
845 /// is being emitted. \p Loc is the location information to use in the
846 /// diagnostic. If line table information is available, the diagnostic
847 /// will include the source code location. \p Msg is the message to show.
848 /// Note that this class does not copy this message, so this reference
849 /// must be valid for the whole life time of the diagnostic.
850 OptimizationRemarkMissed(const char *PassName, const Function &Fn,
851 const DiagnosticLocation &Loc, const Twine &Msg)
853 PassName, Fn, Loc, Msg) {}
854};
855
856/// Diagnostic information for optimization analysis remarks.
859public:
860 /// \p PassName is the name of the pass emitting this diagnostic. If this name
861 /// matches the regular expression given in -Rpass-analysis=, then the
862 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
863 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
864 /// CodeRegion is the region that the optimization operates on.
866 const DiagnosticLocation &Loc,
867 const BasicBlock *CodeRegion);
868
869 /// This is ctor variant allows a pass to build an optimization remark
870 /// from an existing remark.
871 ///
872 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
873 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
874 /// remark. The string \p Prepend will be emitted before the original
875 /// message.
879
880 /// Same as above but \p Inst is used to derive code region and debug
881 /// location.
882 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
883 const Instruction *Inst);
884
885 /// Same as above but \p F is used to derive code region and debug
886 /// location.
887 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
888 const Function *F);
889
890 static bool classof(const DiagnosticInfo *DI) {
892 }
893
894 /// \see DiagnosticInfoOptimizationBase::isEnabled.
895 bool isEnabled() const override;
896
897 static const char *AlwaysPrint;
898
899 bool shouldAlwaysPrint() const { return getPassName() == AlwaysPrint; }
900
901protected:
903 const Function &Fn, const DiagnosticLocation &Loc,
904 const Twine &Msg)
906
908 StringRef RemarkName,
909 const DiagnosticLocation &Loc,
910 const BasicBlock *CodeRegion);
911
912private:
913 /// This is deprecated now and only used by the function API below.
914 /// \p PassName is the name of the pass emitting this diagnostic. If
915 /// this name matches the regular expression given in -Rpass-analysis=, then
916 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
917 /// is being emitted. \p Loc is the location information to use in the
918 /// diagnostic. If line table information is available, the diagnostic will
919 /// include the source code location. \p Msg is the message to show. Note that
920 /// this class does not copy this message, so this reference must be valid for
921 /// the whole life time of the diagnostic.
922 OptimizationRemarkAnalysis(const char *PassName, const Function &Fn,
923 const DiagnosticLocation &Loc, const Twine &Msg)
925 PassName, Fn, Loc, Msg) {}
926};
927
928/// Diagnostic information for optimization analysis remarks related to
929/// floating-point non-commutativity.
932 void anchor() override;
933public:
934 /// \p PassName is the name of the pass emitting this diagnostic. If this name
935 /// matches the regular expression given in -Rpass-analysis=, then the
936 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
937 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
938 /// CodeRegion is the region that the optimization operates on. The front-end
939 /// will append its own message related to options that address floating-point
940 /// non-commutativity.
947
948 static bool classof(const DiagnosticInfo *DI) {
950 }
951
952private:
953 /// This is deprecated now and only used by the function API below.
954 /// \p PassName is the name of the pass emitting this diagnostic. If
955 /// this name matches the regular expression given in -Rpass-analysis=, then
956 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
957 /// is being emitted. \p Loc is the location information to use in the
958 /// diagnostic. If line table information is available, the diagnostic will
959 /// include the source code location. \p Msg is the message to show. The
960 /// front-end will append its own message related to options that address
961 /// floating-point non-commutativity. Note that this class does not copy this
962 /// message, so this reference must be valid for the whole life time of the
963 /// diagnostic.
965 const DiagnosticLocation &Loc,
966 const Twine &Msg)
968 PassName, Fn, Loc, Msg) {}
969};
970
971/// Diagnostic information for optimization analysis remarks related to
972/// pointer aliasing.
975 void anchor() override;
976public:
977 /// \p PassName is the name of the pass emitting this diagnostic. If this name
978 /// matches the regular expression given in -Rpass-analysis=, then the
979 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
980 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
981 /// CodeRegion is the region that the optimization operates on. The front-end
982 /// will append its own message related to options that address pointer
983 /// aliasing legality.
989
990 static bool classof(const DiagnosticInfo *DI) {
992 }
993
994private:
995 /// This is deprecated now and only used by the function API below.
996 /// \p PassName is the name of the pass emitting this diagnostic. If
997 /// this name matches the regular expression given in -Rpass-analysis=, then
998 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
999 /// is being emitted. \p Loc is the location information to use in the
1000 /// diagnostic. If line table information is available, the diagnostic will
1001 /// include the source code location. \p Msg is the message to show. The
1002 /// front-end will append its own message related to options that address
1003 /// pointer aliasing legality. Note that this class does not copy this
1004 /// message, so this reference must be valid for the whole life time of the
1005 /// diagnostic.
1007 const DiagnosticLocation &Loc,
1008 const Twine &Msg)
1010 PassName, Fn, Loc, Msg) {}
1011};
1012
1013/// Diagnostic information for machine IR parser.
1014// FIXME: Remove this, use DiagnosticInfoSrcMgr instead.
1016 const SMDiagnostic &Diagnostic;
1017
1018public:
1020 const SMDiagnostic &Diagnostic)
1021 : DiagnosticInfo(DK_MIRParser, Severity), Diagnostic(Diagnostic) {}
1022
1023 const SMDiagnostic &getDiagnostic() const { return Diagnostic; }
1024
1025 void print(DiagnosticPrinter &DP) const override;
1026
1027 static bool classof(const DiagnosticInfo *DI) {
1028 return DI->getKind() == DK_MIRParser;
1029 }
1030};
1031
1032/// Diagnostic information for IR instrumentation reporting.
1034 const Twine &Msg;
1035
1036public:
1038 DiagnosticSeverity Severity = DS_Warning)
1039 : DiagnosticInfo(DK_Instrumentation, Severity), Msg(DiagMsg) {}
1040
1041 void print(DiagnosticPrinter &DP) const override;
1042
1043 static bool classof(const DiagnosticInfo *DI) {
1044 return DI->getKind() == DK_Instrumentation;
1045 }
1046};
1047
1048/// Diagnostic information for ISel fallback path.
1050 /// The function that is concerned by this diagnostic.
1051 const Function &Fn;
1052
1053public:
1055 DiagnosticSeverity Severity = DS_Warning)
1056 : DiagnosticInfo(DK_ISelFallback, Severity), Fn(Fn) {}
1057
1058 const Function &getFunction() const { return Fn; }
1059
1060 void print(DiagnosticPrinter &DP) const override;
1061
1062 static bool classof(const DiagnosticInfo *DI) {
1063 return DI->getKind() == DK_ISelFallback;
1064 }
1065};
1066
1067// Create wrappers for C Binding types (see CBindingWrapping.h).
1069
1070/// Diagnostic information for optimization failures.
1073public:
1074 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1075 /// the location information to use in the diagnostic. If line table
1076 /// information is available, the diagnostic will include the source code
1077 /// location. \p Msg is the message to show. Note that this class does not
1078 /// copy this message, so this reference must be valid for the whole life time
1079 /// of the diagnostic.
1085
1086 /// \p PassName is the name of the pass emitting this diagnostic. \p
1087 /// RemarkName is a textual identifier for the remark (single-word,
1088 /// CamelCase). \p Loc is the debug location and \p CodeRegion is the
1089 /// region that the optimization operates on.
1091 const DiagnosticLocation &Loc,
1092 const BasicBlock *CodeRegion);
1093
1094 static bool classof(const DiagnosticInfo *DI) {
1095 return DI->getKind() == DK_OptimizationFailure;
1096 }
1097
1098 /// \see DiagnosticInfoOptimizationBase::isEnabled.
1099 bool isEnabled() const override;
1100};
1101
1102/// Diagnostic information for unsupported feature in backend.
1105private:
1106 const Twine &Msg;
1107
1108public:
1109 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1110 /// the location information to use in the diagnostic. If line table
1111 /// information is available, the diagnostic will include the source code
1112 /// location. \p Msg is the message to show. Note that this class does not
1113 /// copy this message, so this reference must be valid for the whole life time
1114 /// of the diagnostic.
1116 const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
1118 DiagnosticSeverity Severity = DS_Error)
1119 : DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
1120 Msg(Msg) {}
1121
1122 static bool classof(const DiagnosticInfo *DI) {
1123 return DI->getKind() == DK_Unsupported;
1124 }
1125
1126 const Twine &getMessage() const { return Msg; }
1127
1128 void print(DiagnosticPrinter &DP) const override;
1129};
1130
1131/// Diagnostic information for unsupported target intrinsics in backend.
1134private:
1135 unsigned IntrinsicID;
1136 StringRef RequiredFeatures;
1137
1138public:
1140 const Function &Fn, unsigned IntrinsicID,
1141 const DiagnosticLocation &Loc = DiagnosticLocation());
1142
1143 static bool classof(const DiagnosticInfo *DI) {
1144 return DI->getKind() == DK_UnsupportedTargetIntrinsic;
1145 }
1146
1147 unsigned getIntrinsicID() const { return IntrinsicID; }
1148 StringRef getRequiredFeatures() const { return RequiredFeatures; }
1149 std::string getMessage() const;
1150
1151 void print(DiagnosticPrinter &DP) const override;
1152};
1153
1154/// Diagnostic information for MisExpect analysis.
1156public:
1158 const Twine &Msg LLVM_LIFETIME_BOUND);
1159
1160 /// \see DiagnosticInfo::print.
1161 void print(DiagnosticPrinter &DP) const override;
1162
1163 static bool classof(const DiagnosticInfo *DI) {
1164 return DI->getKind() == DK_MisExpect;
1165 }
1166
1167 const Twine &getMsg() const { return Msg; }
1168
1169private:
1170 /// Message to report.
1171 const Twine &Msg;
1172};
1173
1175 switch (DK) {
1177 return DS_Error;
1178 break;
1180 return DS_Warning;
1181 break;
1183 return DS_Note;
1184 break;
1186 return DS_Remark;
1187 break;
1188 }
1189 llvm_unreachable("unknown SourceMgr::DiagKind");
1190}
1191
1192/// Diagnostic information for SMDiagnostic reporting.
1194 const SMDiagnostic &Diagnostic;
1195 StringRef ModName;
1196
1197 // For inlineasm !srcloc translation.
1198 bool InlineAsmDiag;
1199 uint64_t LocCookie;
1200
1201public:
1202 DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName,
1203 bool InlineAsmDiag = true, uint64_t LocCookie = 0)
1205 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1206 LocCookie(LocCookie) {}
1207
1208 StringRef getModuleName() const { return ModName; }
1209 bool isInlineAsmDiag() const { return InlineAsmDiag; }
1210 const SMDiagnostic &getSMDiag() const { return Diagnostic; }
1211 uint64_t getLocCookie() const { return LocCookie; }
1212 void print(DiagnosticPrinter &DP) const override;
1213
1214 static bool classof(const DiagnosticInfo *DI) {
1215 return DI->getKind() == DK_SrcMgr;
1216 }
1217};
1218
1219LLVM_ABI void diagnoseDontCall(const CallInst &CI);
1220
1221/// Inlining location extracted from debug info.
1228
1230 StringRef CalleeName;
1231 StringRef Note;
1232 uint64_t LocCookie;
1233 MDNode *InlinedFromMD = nullptr;
1234 SmallVector<DebugInlineInfo, 4> DebugInlineChain;
1235
1236public:
1238 DiagnosticSeverity DS, uint64_t LocCookie,
1239 MDNode *InlinedFromMD = nullptr)
1240 : DiagnosticInfo(DK_DontCall, DS), CalleeName(CalleeName), Note(Note),
1241 LocCookie(LocCookie), InlinedFromMD(InlinedFromMD) {}
1242
1243 StringRef getFunctionName() const { return CalleeName; }
1244 StringRef getNote() const { return Note; }
1245 uint64_t getLocCookie() const { return LocCookie; }
1246 MDNode *getInlinedFromMD() const { return InlinedFromMD; }
1247 SmallVector<std::pair<StringRef, uint64_t>> getInliningDecisions() const;
1248
1250 DebugInlineChain = std::move(Chain);
1251 }
1253 return DebugInlineChain;
1254 }
1255
1256 void print(DiagnosticPrinter &DP) const override;
1257 static bool classof(const DiagnosticInfo *DI) {
1258 return DI->getKind() == DK_DontCall;
1259 }
1260};
1261
1262} // end namespace llvm
1263
1264#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:215
#define LLVM_LIFETIME_BOUND
Definition Compiler.h:437
#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
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
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.
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:1069
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:303
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
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: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.
@ 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:2208
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.