LLVM 22.0.0git
DiagnosticInfo.h
Go to the documentation of this file.
1//===- llvm/IR/DiagnosticInfo.h - Diagnostic Declaration --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the different classes involved in low level diagnostics.
10//
11// Diagnostics reporting is still done as part of the LLVMContext.
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_DIAGNOSTICINFO_H
15#define LLVM_IR_DIAGNOSTICINFO_H
16
17#include "llvm-c/Types.h"
18#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/IR/DebugLoc.h"
28#include <algorithm>
29#include <cstdint>
30#include <functional>
31#include <iterator>
32#include <optional>
33#include <string>
34#include <utility>
35
36namespace llvm {
37
38// Forward declarations.
39class DiagnosticPrinter;
40class DIFile;
41class DISubprogram;
42class CallInst;
43class Function;
44class Instruction;
45class InstructionCost;
46class Module;
47class Type;
48class Value;
49
50/// Defines the different supported severity of a diagnostic.
51enum DiagnosticSeverity : char {
55 // A note attaches additional information to one of the previous diagnostic
56 // types.
58};
59
60/// Defines the different supported kind of a diagnostic.
61/// This enum should be extended with a new ID for each added concrete subclass.
96 DK_FirstPluginKind // Must be last value to work with
97 // getNextAvailablePluginDiagnosticKind
98};
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,
225 DiagnosticSeverity Severity = DS_Warning)
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 debug metadata version diagnostic.
245 const Module &M;
246
247public:
248 /// \p The module that is concerned by this debug metadata version diagnostic.
250 const Module &M, DiagnosticSeverity Severity = DS_Warning)
251 : DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M) {}
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) {}
277 DiagnosticSeverity Severity = DS_Error)
278 : DiagnosticInfo(DK_SampleProfile, Severity), 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 char *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.
484 DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName,
485 uint64_t ResourceSize, uint64_t ResourceLimit,
488
489 const Function &getFunction() const { return Fn; }
490 const char *getResourceName() const { return ResourceName; }
491 uint64_t getResourceSize() const { return ResourceSize; }
492 uint64_t getResourceLimit() const { return ResourceLimit; }
493
494 /// \see DiagnosticInfo::print.
495 void print(DiagnosticPrinter &DP) const override;
496
497 static bool classof(const DiagnosticInfo *DI) {
498 return DI->getKind() == DK_ResourceLimit || DI->getKind() == DK_StackSize;
499 }
500};
501
503 void anchor() override;
504
505public:
507 uint64_t StackLimit,
508 DiagnosticSeverity Severity = DS_Warning)
509 : DiagnosticInfoResourceLimit(Fn, "stack frame size", StackSize,
510 StackLimit, Severity, DK_StackSize) {}
511
512 uint64_t getStackSize() const { return getResourceSize(); }
513 uint64_t getStackLimit() const { return getResourceLimit(); }
514
515 static bool classof(const DiagnosticInfo *DI) {
516 return DI->getKind() == DK_StackSize;
517 }
518};
519
520/// Common features for diagnostics dealing with optimization remarks
521/// that are used by both IR and MIR passes.
524public:
525 /// Used to set IsVerbose via the stream interface.
526 struct setIsVerbose {};
527
528 /// When an instance of this is inserted into the stream, the arguments
529 /// following will not appear in the remark printed in the compiler output
530 /// (-Rpass) but only in the optimization record file
531 /// (-fsave-optimization-record).
532 struct setExtraArgs {};
533
534 /// Used in the streaming interface as the general argument type. It
535 /// internally converts everything into a key-value pair.
536 struct Argument {
537 std::string Key;
538 std::string Val;
539 // If set, the debug location corresponding to the value.
541
542 explicit Argument(StringRef Str = "") : Key("String"), Val(Str) {}
543 LLVM_ABI Argument(StringRef Key, const Value *V);
544 LLVM_ABI Argument(StringRef Key, const Type *T);
546 Argument(StringRef Key, const char *S) : Argument(Key, StringRef(S)) {};
547 LLVM_ABI Argument(StringRef Key, int N);
548 LLVM_ABI Argument(StringRef Key, float N);
549 LLVM_ABI Argument(StringRef Key, long N);
550 LLVM_ABI Argument(StringRef Key, long long N);
551 LLVM_ABI Argument(StringRef Key, unsigned N);
552 LLVM_ABI Argument(StringRef Key, unsigned long N);
553 LLVM_ABI Argument(StringRef Key, unsigned long long N);
555 Argument(StringRef Key, bool B) : Key(Key), Val(B ? "true" : "false") {}
558 };
559
560 /// \p PassName is the name of the pass emitting this diagnostic. \p
561 /// RemarkName is a textual identifier for the remark (single-word,
562 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
563 /// \p Loc is the location information to use in the diagnostic. If line table
564 /// information is available, the diagnostic will include the source code
565 /// location.
567 enum DiagnosticSeverity Severity,
568 const char *PassName, StringRef RemarkName,
569 const Function &Fn,
570 const DiagnosticLocation &Loc)
571 : DiagnosticInfoWithLocationBase(Kind, Severity, Fn, Loc),
572 PassName(PassName), RemarkName(RemarkName) {}
573
574 void insert(StringRef S);
575 void insert(Argument A);
576 void insert(setIsVerbose V);
577 void insert(setExtraArgs EA);
578
579 /// \see DiagnosticInfo::print.
580 void print(DiagnosticPrinter &DP) const override;
581
582 /// Return true if this optimization remark is enabled by one of
583 /// of the LLVM command line flags (-pass-remarks, -pass-remarks-missed,
584 /// or -pass-remarks-analysis). Note that this only handles the LLVM
585 /// flags. We cannot access Clang flags from here (they are handled
586 /// in BackendConsumer::OptimizationRemarkHandler).
587 virtual bool isEnabled() const = 0;
588
589 StringRef getPassName() const { return PassName; }
590 StringRef getRemarkName() const { return RemarkName; }
591 std::string getMsg() const;
592 std::optional<uint64_t> getHotness() const { return Hotness; }
593 void setHotness(std::optional<uint64_t> H) { Hotness = H; }
594
595 bool isVerbose() const { return IsVerbose; }
596
597 ArrayRef<Argument> getArgs() const { return Args; }
598
599 static bool classof(const DiagnosticInfo *DI) {
600 return (DI->getKind() >= DK_FirstRemark &&
601 DI->getKind() <= DK_LastRemark) ||
602 (DI->getKind() >= DK_FirstMachineRemark &&
604 }
605
606 bool isPassed() const {
607 return (getKind() == DK_OptimizationRemark ||
608 getKind() == DK_MachineOptimizationRemark);
609 }
610
611 bool isMissed() const {
612 return (getKind() == DK_OptimizationRemarkMissed ||
614 }
615
616 bool isAnalysis() const {
617 return (getKind() == DK_OptimizationRemarkAnalysis ||
619 }
620
621protected:
622 /// Name of the pass that triggers this report. If this matches the
623 /// regular expression given in -Rpass=regexp, then the remark will
624 /// be emitted.
625 const char *PassName;
626
627 /// Textual identifier for the remark (single-word, CamelCase). Can be used
628 /// by external tools reading the output file for optimization remarks to
629 /// identify the remark.
631
632 /// If profile information is available, this is the number of times the
633 /// corresponding code was executed in a profile instrumentation run.
634 std::optional<uint64_t> Hotness;
635
636 /// Arguments collected via the streaming interface.
638
639 /// The remark is expected to be noisy.
640 bool IsVerbose = false;
641
642 /// If positive, the index of the first argument that only appear in
643 /// the optimization records and not in the remark printed in the compiler
644 /// output.
645 int FirstExtraArgIndex = -1;
646};
647
648/// Allow the insertion operator to return the actual remark type rather than a
649/// common base class. This allows returning the result of the insertion
650/// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah".
651template <class RemarkT>
652decltype(auto)
653operator<<(RemarkT &&R,
654 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
655 std::remove_reference_t<RemarkT>>,
656 StringRef>
657 S) {
658 R.insert(S);
659 return std::forward<RemarkT>(R);
660}
661
662template <class RemarkT>
663decltype(auto)
664operator<<(RemarkT &&R,
665 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
666 std::remove_reference_t<RemarkT>>,
668 A) {
669 R.insert(A);
670 return std::forward<RemarkT>(R);
671}
672
673template <class RemarkT>
674decltype(auto)
675operator<<(RemarkT &&R,
676 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
677 std::remove_reference_t<RemarkT>>,
679 V) {
680 R.insert(V);
681 return std::forward<RemarkT>(R);
682}
683
684template <class RemarkT>
685decltype(auto)
686operator<<(RemarkT &&R,
687 std::enable_if_t<std::is_base_of_v<DiagnosticInfoOptimizationBase,
688 std::remove_reference_t<RemarkT>>,
690 EA) {
691 R.insert(EA);
692 return std::forward<RemarkT>(R);
693}
694
695/// Common features for diagnostics dealing with optimization remarks
696/// that are used by IR passes.
699 void anchor() override;
700public:
701 /// \p PassName is the name of the pass emitting this diagnostic. \p
702 /// RemarkName is a textual identifier for the remark (single-word,
703 /// CamelCase). \p Fn is the function where the diagnostic is being emitted.
704 /// \p Loc is the location information to use in the diagnostic. If line table
705 /// information is available, the diagnostic will include the source code
706 /// location. \p CodeRegion is IR value that the optimization operates on.
707 /// This is currently used to provide run-time hotness information with PGO.
709 enum DiagnosticSeverity Severity,
710 const char *PassName, StringRef RemarkName,
711 const Function &Fn,
712 const DiagnosticLocation &Loc,
713 const BasicBlock *CodeRegion = nullptr)
714 : DiagnosticInfoOptimizationBase(Kind, Severity, PassName, RemarkName, Fn,
715 Loc),
716 CodeRegion(CodeRegion) {}
717
718 /// This is ctor variant allows a pass to build an optimization remark
719 /// from an existing remark.
720 ///
721 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
722 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
723 /// remark. The string \p Prepend will be emitted before the original
724 /// message.
728 (DiagnosticKind)Orig.getKind(), Orig.getSeverity(), PassName,
729 Orig.RemarkName, Orig.getFunction(), Orig.getLocation()),
730 CodeRegion(Orig.getCodeRegion()) {
731 *this << Prepend;
732 llvm::append_range(Args, Orig.Args);
733 }
734
735 /// Legacy interface.
736 /// \p PassName is the name of the pass emitting this diagnostic.
737 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
738 /// the location information to use in the diagnostic. If line table
739 /// information is available, the diagnostic will include the source code
740 /// location. \p Msg is the message to show. Note that this class does not
741 /// copy this message, so this reference must be valid for the whole life time
742 /// of the diagnostic.
744 enum DiagnosticSeverity Severity,
745 const char *PassName, const Function &Fn,
746 const DiagnosticLocation &Loc, const Twine &Msg)
747 : DiagnosticInfoOptimizationBase(Kind, Severity, PassName, "", Fn, Loc) {
748 *this << Msg.str();
749 }
750
751 const BasicBlock *getCodeRegion() const { return CodeRegion; }
752
753 static bool classof(const DiagnosticInfo *DI) {
754 return DI->getKind() >= DK_FirstRemark && DI->getKind() <= DK_LastRemark;
755 }
756
757private:
758 /// The IR region (currently basic block) that the optimization operates on.
759 /// This is currently used to provide run-time hotness information with PGO.
760 const BasicBlock *CodeRegion = nullptr;
761};
762
763/// Diagnostic information for applied optimization remarks.
765public:
766 /// \p PassName is the name of the pass emitting this diagnostic. If this name
767 /// matches the regular expression given in -Rpass=, then the diagnostic will
768 /// be emitted. \p RemarkName is a textual identifier for the remark (single-
769 /// word, CamelCase). \p Loc is the debug location and \p CodeRegion is the
770 /// region that the optimization operates on.
771 OptimizationRemark(const char *PassName, StringRef RemarkName,
772 const DiagnosticLocation &Loc,
773 const BasicBlock *CodeRegion);
774
775 /// Same as above, but the debug location and code region are derived from \p
776 /// Instr.
777 OptimizationRemark(const char *PassName, StringRef RemarkName,
778 const Instruction *Inst);
779
780 /// Same as above, but the debug location and code region are derived from \p
781 /// Func.
782 OptimizationRemark(const char *PassName, StringRef RemarkName,
783 const Function *Func);
784
785 static bool classof(const DiagnosticInfo *DI) {
786 return DI->getKind() == DK_OptimizationRemark;
787 }
788
789 /// \see DiagnosticInfoOptimizationBase::isEnabled.
790 bool isEnabled() const override;
791
792private:
793 /// This is deprecated now and only used by the function API below.
794 /// \p PassName is the name of the pass emitting this diagnostic. If
795 /// this name matches the regular expression given in -Rpass=, then the
796 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
797 /// is being emitted. \p Loc is the location information to use in the
798 /// diagnostic. If line table information is available, the diagnostic
799 /// will include the source code location. \p Msg is the message to show.
800 /// Note that this class does not copy this message, so this reference
801 /// must be valid for the whole life time of the diagnostic.
802 OptimizationRemark(const char *PassName, const Function &Fn,
803 const DiagnosticLocation &Loc, const Twine &Msg)
805 Fn, Loc, Msg) {}
806};
807
808/// Diagnostic information for missed-optimization remarks.
810public:
811 /// \p PassName is the name of the pass emitting this diagnostic. If this name
812 /// matches the regular expression given in -Rpass-missed=, then the
813 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
814 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
815 /// CodeRegion is the region that the optimization operates on.
816 OptimizationRemarkMissed(const char *PassName, StringRef RemarkName,
817 const DiagnosticLocation &Loc,
818 const BasicBlock *CodeRegion);
819
820 /// Same as above but \p Inst is used to derive code region and debug
821 /// location.
822 OptimizationRemarkMissed(const char *PassName, StringRef RemarkName,
823 const Instruction *Inst);
824
825 /// Same as above but \p F is used to derive code region and debug
826 /// location.
827 OptimizationRemarkMissed(const char *PassName, StringRef RemarkName,
828 const Function *F);
829
830 static bool classof(const DiagnosticInfo *DI) {
831 return DI->getKind() == DK_OptimizationRemarkMissed;
832 }
833
834 /// \see DiagnosticInfoOptimizationBase::isEnabled.
835 bool isEnabled() const override;
836
837private:
838 /// This is deprecated now and only used by the function API below.
839 /// \p PassName is the name of the pass emitting this diagnostic. If
840 /// this name matches the regular expression given in -Rpass-missed=, then the
841 /// diagnostic will be emitted. \p Fn is the function where the diagnostic
842 /// is being emitted. \p Loc is the location information to use in the
843 /// diagnostic. If line table information is available, the diagnostic
844 /// will include the source code location. \p Msg is the message to show.
845 /// Note that this class does not copy this message, so this reference
846 /// must be valid for the whole life time of the diagnostic.
847 OptimizationRemarkMissed(const char *PassName, const Function &Fn,
848 const DiagnosticLocation &Loc, const Twine &Msg)
850 PassName, Fn, Loc, Msg) {}
851};
852
853/// Diagnostic information for optimization analysis remarks.
856public:
857 /// \p PassName is the name of the pass emitting this diagnostic. If this name
858 /// matches the regular expression given in -Rpass-analysis=, then the
859 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
860 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
861 /// CodeRegion is the region that the optimization operates on.
862 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
863 const DiagnosticLocation &Loc,
864 const BasicBlock *CodeRegion);
865
866 /// This is ctor variant allows a pass to build an optimization remark
867 /// from an existing remark.
868 ///
869 /// This is useful when a transformation pass (e.g LV) wants to emit a remark
870 /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
871 /// remark. The string \p Prepend will be emitted before the original
872 /// message.
874 const OptimizationRemarkAnalysis &Orig)
875 : DiagnosticInfoIROptimization(PassName, Prepend, Orig) {}
876
877 /// Same as above but \p Inst is used to derive code region and debug
878 /// location.
879 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
880 const Instruction *Inst);
881
882 /// Same as above but \p F is used to derive code region and debug
883 /// location.
884 OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
885 const Function *F);
886
887 static bool classof(const DiagnosticInfo *DI) {
889 }
890
891 /// \see DiagnosticInfoOptimizationBase::isEnabled.
892 bool isEnabled() const override;
893
894 static const char *AlwaysPrint;
895
896 bool shouldAlwaysPrint() const { return getPassName() == AlwaysPrint; }
897
898protected:
900 const Function &Fn, const DiagnosticLocation &Loc,
901 const Twine &Msg)
902 : DiagnosticInfoIROptimization(Kind, DS_Remark, PassName, Fn, Loc, Msg) {}
903
905 StringRef RemarkName,
906 const DiagnosticLocation &Loc,
907 const BasicBlock *CodeRegion);
908
909private:
910 /// This is deprecated now and only used by the function API below.
911 /// \p PassName is the name of the pass emitting this diagnostic. If
912 /// this name matches the regular expression given in -Rpass-analysis=, then
913 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
914 /// is being emitted. \p Loc is the location information to use in the
915 /// diagnostic. If line table information is available, the diagnostic will
916 /// include the source code location. \p Msg is the message to show. Note that
917 /// this class does not copy this message, so this reference must be valid for
918 /// the whole life time of the diagnostic.
919 OptimizationRemarkAnalysis(const char *PassName, const Function &Fn,
920 const DiagnosticLocation &Loc, const Twine &Msg)
922 PassName, Fn, Loc, Msg) {}
923};
924
925/// Diagnostic information for optimization analysis remarks related to
926/// floating-point non-commutativity.
929 void anchor() override;
930public:
931 /// \p PassName is the name of the pass emitting this diagnostic. If this name
932 /// matches the regular expression given in -Rpass-analysis=, then the
933 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
934 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
935 /// CodeRegion is the region that the optimization operates on. The front-end
936 /// will append its own message related to options that address floating-point
937 /// non-commutativity.
939 StringRef RemarkName,
940 const DiagnosticLocation &Loc,
941 const BasicBlock *CodeRegion)
943 PassName, RemarkName, Loc, CodeRegion) {}
944
945 static bool classof(const DiagnosticInfo *DI) {
947 }
948
949private:
950 /// This is deprecated now and only used by the function API below.
951 /// \p PassName is the name of the pass emitting this diagnostic. If
952 /// this name matches the regular expression given in -Rpass-analysis=, then
953 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
954 /// is being emitted. \p Loc is the location information to use in the
955 /// diagnostic. If line table information is available, the diagnostic will
956 /// include the source code location. \p Msg is the message to show. The
957 /// front-end will append its own message related to options that address
958 /// floating-point non-commutativity. Note that this class does not copy this
959 /// message, so this reference must be valid for the whole life time of the
960 /// diagnostic.
962 const DiagnosticLocation &Loc,
963 const Twine &Msg)
965 PassName, Fn, Loc, Msg) {}
966};
967
968/// Diagnostic information for optimization analysis remarks related to
969/// pointer aliasing.
972 void anchor() override;
973public:
974 /// \p PassName is the name of the pass emitting this diagnostic. If this name
975 /// matches the regular expression given in -Rpass-analysis=, then the
976 /// diagnostic will be emitted. \p RemarkName is a textual identifier for the
977 /// remark (single-word, CamelCase). \p Loc is the debug location and \p
978 /// CodeRegion is the region that the optimization operates on. The front-end
979 /// will append its own message related to options that address pointer
980 /// aliasing legality.
982 const DiagnosticLocation &Loc,
983 const BasicBlock *CodeRegion)
985 PassName, RemarkName, Loc, CodeRegion) {}
986
987 static bool classof(const DiagnosticInfo *DI) {
989 }
990
991private:
992 /// This is deprecated now and only used by the function API below.
993 /// \p PassName is the name of the pass emitting this diagnostic. If
994 /// this name matches the regular expression given in -Rpass-analysis=, then
995 /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
996 /// is being emitted. \p Loc is the location information to use in the
997 /// diagnostic. If line table information is available, the diagnostic will
998 /// include the source code location. \p Msg is the message to show. The
999 /// front-end will append its own message related to options that address
1000 /// pointer aliasing legality. Note that this class does not copy this
1001 /// message, so this reference must be valid for the whole life time of the
1002 /// diagnostic.
1004 const DiagnosticLocation &Loc,
1005 const Twine &Msg)
1007 PassName, Fn, Loc, Msg) {}
1008};
1009
1010/// Diagnostic information for machine IR parser.
1011// FIXME: Remove this, use DiagnosticInfoSrcMgr instead.
1013 const SMDiagnostic &Diagnostic;
1014
1015public:
1017 const SMDiagnostic &Diagnostic)
1018 : DiagnosticInfo(DK_MIRParser, Severity), Diagnostic(Diagnostic) {}
1019
1020 const SMDiagnostic &getDiagnostic() const { return Diagnostic; }
1021
1022 void print(DiagnosticPrinter &DP) const override;
1023
1024 static bool classof(const DiagnosticInfo *DI) {
1025 return DI->getKind() == DK_MIRParser;
1026 }
1027};
1028
1029/// Diagnostic information for IR instrumentation reporting.
1031 const Twine &Msg;
1032
1033public:
1035 DiagnosticSeverity Severity = DS_Warning)
1036 : DiagnosticInfo(DK_Instrumentation, Severity), Msg(DiagMsg) {}
1037
1038 void print(DiagnosticPrinter &DP) const override;
1039
1040 static bool classof(const DiagnosticInfo *DI) {
1041 return DI->getKind() == DK_Instrumentation;
1042 }
1043};
1044
1045/// Diagnostic information for ISel fallback path.
1047 /// The function that is concerned by this diagnostic.
1048 const Function &Fn;
1049
1050public:
1052 DiagnosticSeverity Severity = DS_Warning)
1053 : DiagnosticInfo(DK_ISelFallback, Severity), Fn(Fn) {}
1054
1055 const Function &getFunction() const { return Fn; }
1056
1057 void print(DiagnosticPrinter &DP) const override;
1058
1059 static bool classof(const DiagnosticInfo *DI) {
1060 return DI->getKind() == DK_ISelFallback;
1061 }
1062};
1063
1064// Create wrappers for C Binding types (see CBindingWrapping.h).
1066
1067/// Diagnostic information for optimization failures.
1070public:
1071 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1072 /// the location information to use in the diagnostic. If line table
1073 /// information is available, the diagnostic will include the source code
1074 /// location. \p Msg is the message to show. Note that this class does not
1075 /// copy this message, so this reference must be valid for the whole life time
1076 /// of the diagnostic.
1078 const DiagnosticLocation &Loc,
1079 const Twine &Msg)
1081 nullptr, Fn, Loc, Msg) {}
1082
1083 /// \p PassName is the name of the pass emitting this diagnostic. \p
1084 /// RemarkName is a textual identifier for the remark (single-word,
1085 /// CamelCase). \p Loc is the debug location and \p CodeRegion is the
1086 /// region that the optimization operates on.
1088 const DiagnosticLocation &Loc,
1089 const BasicBlock *CodeRegion);
1090
1091 static bool classof(const DiagnosticInfo *DI) {
1092 return DI->getKind() == DK_OptimizationFailure;
1093 }
1094
1095 /// \see DiagnosticInfoOptimizationBase::isEnabled.
1096 bool isEnabled() const override;
1097};
1098
1099/// Diagnostic information for unsupported feature in backend.
1102private:
1103 const Twine &Msg;
1104
1105public:
1106 /// \p Fn is the function where the diagnostic is being emitted. \p Loc is
1107 /// the location information to use in the diagnostic. If line table
1108 /// information is available, the diagnostic will include the source code
1109 /// location. \p Msg is the message to show. Note that this class does not
1110 /// copy this message, so this reference must be valid for the whole life time
1111 /// of the diagnostic.
1113 const Function &Fn, const Twine &Msg LLVM_LIFETIME_BOUND,
1115 DiagnosticSeverity Severity = DS_Error)
1116 : DiagnosticInfoWithLocationBase(DK_Unsupported, Severity, Fn, Loc),
1117 Msg(Msg) {}
1118
1119 static bool classof(const DiagnosticInfo *DI) {
1120 return DI->getKind() == DK_Unsupported;
1121 }
1122
1123 const Twine &getMessage() const { return Msg; }
1124
1125 void print(DiagnosticPrinter &DP) const override;
1126};
1127
1128/// Diagnostic information for MisExpect analysis.
1130public:
1132 const Twine &Msg LLVM_LIFETIME_BOUND);
1133
1134 /// \see DiagnosticInfo::print.
1135 void print(DiagnosticPrinter &DP) const override;
1136
1137 static bool classof(const DiagnosticInfo *DI) {
1138 return DI->getKind() == DK_MisExpect;
1139 }
1140
1141 const Twine &getMsg() const { return Msg; }
1142
1143private:
1144 /// Message to report.
1145 const Twine &Msg;
1146};
1147
1149 switch (DK) {
1151 return DS_Error;
1152 break;
1154 return DS_Warning;
1155 break;
1157 return DS_Note;
1158 break;
1160 return DS_Remark;
1161 break;
1162 }
1163 llvm_unreachable("unknown SourceMgr::DiagKind");
1164}
1165
1166/// Diagnostic information for SMDiagnostic reporting.
1168 const SMDiagnostic &Diagnostic;
1169 StringRef ModName;
1170
1171 // For inlineasm !srcloc translation.
1172 bool InlineAsmDiag;
1173 uint64_t LocCookie;
1174
1175public:
1176 DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName,
1177 bool InlineAsmDiag = true, uint64_t LocCookie = 0)
1178 : DiagnosticInfo(DK_SrcMgr, getDiagnosticSeverity(Diagnostic.getKind())),
1179 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1180 LocCookie(LocCookie) {}
1181
1182 StringRef getModuleName() const { return ModName; }
1183 bool isInlineAsmDiag() const { return InlineAsmDiag; }
1184 const SMDiagnostic &getSMDiag() const { return Diagnostic; }
1185 uint64_t getLocCookie() const { return LocCookie; }
1186 void print(DiagnosticPrinter &DP) const override;
1187
1188 static bool classof(const DiagnosticInfo *DI) {
1189 return DI->getKind() == DK_SrcMgr;
1190 }
1191};
1192
1193LLVM_ABI void diagnoseDontCall(const CallInst &CI);
1194
1196 StringRef CalleeName;
1198 uint64_t LocCookie;
1199
1200public:
1202 DiagnosticSeverity DS, uint64_t LocCookie)
1203 : DiagnosticInfo(DK_DontCall, DS), CalleeName(CalleeName), Note(Note),
1204 LocCookie(LocCookie) {}
1205 StringRef getFunctionName() const { return CalleeName; }
1206 StringRef getNote() const { return Note; }
1207 uint64_t getLocCookie() const { return LocCookie; }
1208 void print(DiagnosticPrinter &DP) const override;
1209 static bool classof(const DiagnosticInfo *DI) {
1210 return DI->getKind() == DK_DontCall;
1211 }
1212};
1213
1214} // end namespace llvm
1215
1216#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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
RelocType Type
Definition: COFFYAML.cpp:410
#define LLVM_ABI
Definition: Compiler.h:213
#define LLVM_LIFETIME_BOUND
Definition: Compiler.h:435
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
#define H(x, y, z)
Definition: MD5.cpp:57
Machine Check Debug Module
static MemoryLocation getLocation(Instruction *I)
This file defines the SmallVector class.
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
static const char PassName[]
This class represents an incoming formal argument to a Function.
Definition: Argument.h:32
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:62
Subprogram description. Uses SubclassData1.
A debug info location.
Definition: DebugLoc.h:124
Diagnostic information for debug metadata version reporting.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion, DiagnosticSeverity Severity=DS_Warning)
The module that is concerned by this debug metadata version diagnostic.
DiagnosticInfoDontCall(StringRef CalleeName, StringRef Note, DiagnosticSeverity DS, uint64_t LocCookie)
static bool classof(const DiagnosticInfo *DI)
StringRef getFunctionName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoGenericWithLoc(const Twine &MsgStr, const Function &Fn, const DiagnosticLocation &Loc, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoGeneric(const Instruction *I, const Twine &ErrMsg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
DiagnosticInfoGeneric(const Twine &MsgStr LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
const Twine & getMsgStr() const
const Instruction * getInstruction() const
Common features for diagnostics dealing with optimization remarks that are used by IR passes.
DiagnosticInfoIROptimization(const char *PassName, StringRef Prepend, const DiagnosticInfoIROptimization &Orig)
This is ctor variant allows a pass to build an optimization remark from an existing remark.
DiagnosticInfoIROptimization(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, StringRef RemarkName, const Function &Fn, const DiagnosticLocation &Loc, const BasicBlock *CodeRegion=nullptr)
PassName is the name of the pass emitting this diagnostic.
DiagnosticInfoIROptimization(enum DiagnosticKind Kind, enum DiagnosticSeverity Severity, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface.
const BasicBlock * getCodeRegion() const
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for ISel fallback path.
static bool classof(const DiagnosticInfo *DI)
const Function & getFunction() const
DiagnosticInfoISelFallback(const Function &Fn, DiagnosticSeverity Severity=DS_Warning)
Diagnostic information for stripping invalid debug metadata.
DiagnosticInfoIgnoringInvalidDebugMetadata(const Module &M, DiagnosticSeverity Severity=DS_Warning)
The module that is concerned by this debug metadata version diagnostic.
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for inline asm reporting.
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
Diagnostic information for IR instrumentation reporting.
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)
Diagnostic information for machine IR parser.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoMIRParser(DiagnosticSeverity Severity, const SMDiagnostic &Diagnostic)
const SMDiagnostic & getDiagnostic() const
Diagnostic information for MisExpect analysis.
const Twine & getMsg() const
static bool classof(const DiagnosticInfo *DI)
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
ArrayRef< Argument > getArgs() const
const char * PassName
Name of the pass that triggers this report.
StringRef RemarkName
Textual identifier for the remark (single-word, CamelCase).
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)
Diagnostic information for the PGO profiler.
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
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for stack size etc.
const Function & getFunction() const
const char * getResourceName() const
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for the sample profiler.
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)
Diagnostic information for SMDiagnostic reporting.
static bool classof(const DiagnosticInfo *DI)
const SMDiagnostic & getSMDiag() const
DiagnosticInfoSrcMgr(const SMDiagnostic &Diagnostic, StringRef ModName, bool InlineAsmDiag=true, uint64_t LocCookie=0)
uint64_t getLocCookie() const
StringRef getModuleName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize, uint64_t StackLimit, DiagnosticSeverity Severity=DS_Warning)
Diagnostic information for unsupported feature in backend.
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)
Common features for diagnostics with an associated location.
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.
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.
unsigned getLine() 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.
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(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)
Diagnostic information for applied optimization remarks.
static bool classof(const DiagnosticInfo *DI)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:282
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:75
struct LLVMOpaqueDiagnosticInfo * LLVMDiagnosticInfoRef
Definition: Types.h:150
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:2155
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_DebugMetadataInvalid
@ DK_SrcMgr
@ DK_Instrumentation
@ DK_OptimizationRemarkAnalysis
@ DK_LastMachineRemark
@ DK_OptimizationRemarkAnalysisAliasing
@ DK_StackSize
@ DK_SampleProfile
@ DK_MachineOptimizationRemark
@ DK_Unsupported
@ DK_LastRemark
@ DK_OptimizationRemarkMissed
@ DK_MIRParser
@ DK_GenericWithLoc
@ DK_ResourceLimit
@ DK_MachineOptimizationRemarkAnalysis
@ DK_ISelFallback
@ DK_Lowering
@ DK_OptimizationRemark
@ DK_FirstMachineRemark
@ DK_DontCall
@ DK_MachineOptimizationRemarkMissed
@ DK_PGOProfile
@ DK_InlineAsm
@ DK_Generic
@ DK_DebugMetadataVersion
@ DK_OptimizationFailure
@ DK_FirstRemark
@ DK_MisExpect
@ DK_LegalizationFailure
@ DK_OptimizationRemarkAnalysisFPCommute
@ DK_FirstPluginKind
@ DK_RegAllocFailure
@ DK_Linker
LLVM_ABI int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
@ DS_Remark
@ DS_Warning
@ DS_Error
static DiagnosticSeverity getDiagnosticSeverity(SourceMgr::DiagKind DK)
std::function< void(const DiagnosticInfo &)> DiagnosticHandlerFunction
#define N
Used in the streaming interface as the general argument type.
When an instance of this is inserted into the stream, the arguments following will not appear in the ...
Used to set IsVerbose via the stream interface.