Macro debug info support in LLVM IR
[oota-llvm.git] / include / llvm / IR / DiagnosticInfo.h
1 //===- llvm/Support/DiagnosticInfo.h - Diagnostic Declaration ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the different classes involved in low level diagnostics.
11 //
12 // Diagnostics reporting is still done as part of the LLVMContext.
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_IR_DIAGNOSTICINFO_H
16 #define LLVM_IR_DIAGNOSTICINFO_H
17
18 #include "llvm-c/Core.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/IR/DebugLoc.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/Support/Casting.h"
23 #include <functional>
24
25 namespace llvm {
26
27 // Forward declarations.
28 class DiagnosticPrinter;
29 class Function;
30 class Instruction;
31 class LLVMContextImpl;
32 class Twine;
33 class Value;
34 class DebugLoc;
35 class SMDiagnostic;
36
37 /// \brief Defines the different supported severity of a diagnostic.
38 enum DiagnosticSeverity {
39   DS_Error,
40   DS_Warning,
41   DS_Remark,
42   // A note attaches additional information to one of the previous diagnostic
43   // types.
44   DS_Note
45 };
46
47 /// \brief Defines the different supported kind of a diagnostic.
48 /// This enum should be extended with a new ID for each added concrete subclass.
49 enum DiagnosticKind {
50   DK_Bitcode,
51   DK_InlineAsm,
52   DK_StackSize,
53   DK_Linker,
54   DK_DebugMetadataVersion,
55   DK_SampleProfile,
56   DK_OptimizationRemark,
57   DK_OptimizationRemarkMissed,
58   DK_OptimizationRemarkAnalysis,
59   DK_OptimizationRemarkAnalysisFPCommute,
60   DK_OptimizationRemarkAnalysisAliasing,
61   DK_OptimizationFailure,
62   DK_MIRParser,
63   DK_PGOProfile,
64   DK_FirstPluginKind
65 };
66
67 /// \brief Get the next available kind ID for a plugin diagnostic.
68 /// Each time this function is called, it returns a different number.
69 /// Therefore, a plugin that wants to "identify" its own classes
70 /// with a dynamic identifier, just have to use this method to get a new ID
71 /// and assign it to each of its classes.
72 /// The returned ID will be greater than or equal to DK_FirstPluginKind.
73 /// Thus, the plugin identifiers will not conflict with the
74 /// DiagnosticKind values.
75 int getNextAvailablePluginDiagnosticKind();
76
77 /// \brief This is the base abstract class for diagnostic reporting in
78 /// the backend.
79 /// The print method must be overloaded by the subclasses to print a
80 /// user-friendly message in the client of the backend (let us call it a
81 /// frontend).
82 class DiagnosticInfo {
83 private:
84   /// Kind defines the kind of report this is about.
85   const /* DiagnosticKind */ int Kind;
86   /// Severity gives the severity of the diagnostic.
87   const DiagnosticSeverity Severity;
88
89 public:
90   DiagnosticInfo(/* DiagnosticKind */ int Kind, DiagnosticSeverity Severity)
91       : Kind(Kind), Severity(Severity) {}
92
93   virtual ~DiagnosticInfo() {}
94
95   /* DiagnosticKind */ int getKind() const { return Kind; }
96   DiagnosticSeverity getSeverity() const { return Severity; }
97
98   /// Print using the given \p DP a user-friendly message.
99   /// This is the default message that will be printed to the user.
100   /// It is used when the frontend does not directly take advantage
101   /// of the information contained in fields of the subclasses.
102   /// The printed message must not end with '.' nor start with a severity
103   /// keyword.
104   virtual void print(DiagnosticPrinter &DP) const = 0;
105
106   static const char *AlwaysPrint;
107 };
108
109 typedef std::function<void(const DiagnosticInfo &)> DiagnosticHandlerFunction;
110
111 /// Diagnostic information for inline asm reporting.
112 /// This is basically a message and an optional location.
113 class DiagnosticInfoInlineAsm : public DiagnosticInfo {
114 private:
115   /// Optional line information. 0 if not set.
116   unsigned LocCookie;
117   /// Message to be reported.
118   const Twine &MsgStr;
119   /// Optional origin of the problem.
120   const Instruction *Instr;
121
122 public:
123   /// \p MsgStr is the message to be reported to the frontend.
124   /// This class does not copy \p MsgStr, therefore the reference must be valid
125   /// for the whole life time of the Diagnostic.
126   DiagnosticInfoInlineAsm(const Twine &MsgStr,
127                           DiagnosticSeverity Severity = DS_Error)
128       : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
129         Instr(nullptr) {}
130
131   /// \p LocCookie if non-zero gives the line number for this report.
132   /// \p MsgStr gives the message.
133   /// This class does not copy \p MsgStr, therefore the reference must be valid
134   /// for the whole life time of the Diagnostic.
135   DiagnosticInfoInlineAsm(unsigned LocCookie, const Twine &MsgStr,
136                           DiagnosticSeverity Severity = DS_Error)
137       : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(LocCookie),
138         MsgStr(MsgStr), Instr(nullptr) {}
139
140   /// \p Instr gives the original instruction that triggered the diagnostic.
141   /// \p MsgStr gives the message.
142   /// This class does not copy \p MsgStr, therefore the reference must be valid
143   /// for the whole life time of the Diagnostic.
144   /// Same for \p I.
145   DiagnosticInfoInlineAsm(const Instruction &I, const Twine &MsgStr,
146                           DiagnosticSeverity Severity = DS_Error);
147
148   unsigned getLocCookie() const { return LocCookie; }
149   const Twine &getMsgStr() const { return MsgStr; }
150   const Instruction *getInstruction() const { return Instr; }
151
152   /// \see DiagnosticInfo::print.
153   void print(DiagnosticPrinter &DP) const override;
154
155   static bool classof(const DiagnosticInfo *DI) {
156     return DI->getKind() == DK_InlineAsm;
157   }
158 };
159
160 /// Diagnostic information for stack size reporting.
161 /// This is basically a function and a size.
162 class DiagnosticInfoStackSize : public DiagnosticInfo {
163 private:
164   /// The function that is concerned by this stack size diagnostic.
165   const Function &Fn;
166   /// The computed stack size.
167   unsigned StackSize;
168
169 public:
170   /// \p The function that is concerned by this stack size diagnostic.
171   /// \p The computed stack size.
172   DiagnosticInfoStackSize(const Function &Fn, unsigned StackSize,
173                           DiagnosticSeverity Severity = DS_Warning)
174       : DiagnosticInfo(DK_StackSize, Severity), Fn(Fn), StackSize(StackSize) {}
175
176   const Function &getFunction() const { return Fn; }
177   unsigned getStackSize() const { return StackSize; }
178
179   /// \see DiagnosticInfo::print.
180   void print(DiagnosticPrinter &DP) const override;
181
182   static bool classof(const DiagnosticInfo *DI) {
183     return DI->getKind() == DK_StackSize;
184   }
185 };
186
187 /// Diagnostic information for debug metadata version reporting.
188 /// This is basically a module and a version.
189 class DiagnosticInfoDebugMetadataVersion : public DiagnosticInfo {
190 private:
191   /// The module that is concerned by this debug metadata version diagnostic.
192   const Module &M;
193   /// The actual metadata version.
194   unsigned MetadataVersion;
195
196 public:
197   /// \p The module that is concerned by this debug metadata version diagnostic.
198   /// \p The actual metadata version.
199   DiagnosticInfoDebugMetadataVersion(const Module &M, unsigned MetadataVersion,
200                           DiagnosticSeverity Severity = DS_Warning)
201       : DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M),
202         MetadataVersion(MetadataVersion) {}
203
204   const Module &getModule() const { return M; }
205   unsigned getMetadataVersion() const { return MetadataVersion; }
206
207   /// \see DiagnosticInfo::print.
208   void print(DiagnosticPrinter &DP) const override;
209
210   static bool classof(const DiagnosticInfo *DI) {
211     return DI->getKind() == DK_DebugMetadataVersion;
212   }
213 };
214
215 /// Diagnostic information for the sample profiler.
216 class DiagnosticInfoSampleProfile : public DiagnosticInfo {
217 public:
218   DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum,
219                               const Twine &Msg,
220                               DiagnosticSeverity Severity = DS_Error)
221       : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
222         LineNum(LineNum), Msg(Msg) {}
223   DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg,
224                               DiagnosticSeverity Severity = DS_Error)
225       : DiagnosticInfo(DK_SampleProfile, Severity), FileName(FileName),
226         LineNum(0), Msg(Msg) {}
227   DiagnosticInfoSampleProfile(const Twine &Msg,
228                               DiagnosticSeverity Severity = DS_Error)
229       : DiagnosticInfo(DK_SampleProfile, Severity), LineNum(0), Msg(Msg) {}
230
231   /// \see DiagnosticInfo::print.
232   void print(DiagnosticPrinter &DP) const override;
233
234   static bool classof(const DiagnosticInfo *DI) {
235     return DI->getKind() == DK_SampleProfile;
236   }
237
238   StringRef getFileName() const { return FileName; }
239   unsigned getLineNum() const { return LineNum; }
240   const Twine &getMsg() const { return Msg; }
241
242 private:
243   /// Name of the input file associated with this diagnostic.
244   StringRef FileName;
245
246   /// Line number where the diagnostic occurred. If 0, no line number will
247   /// be emitted in the message.
248   unsigned LineNum;
249
250   /// Message to report.
251   const Twine &Msg;
252 };
253
254 /// Diagnostic information for the PGO profiler.
255 class DiagnosticInfoPGOProfile : public DiagnosticInfo {
256 public:
257   DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg,
258                            DiagnosticSeverity Severity = DS_Error)
259       : DiagnosticInfo(DK_PGOProfile, Severity), FileName(FileName), Msg(Msg) {}
260
261   /// \see DiagnosticInfo::print.
262   void print(DiagnosticPrinter &DP) const override;
263
264   static bool classof(const DiagnosticInfo *DI) {
265     return DI->getKind() == DK_PGOProfile;
266   }
267
268   const char *getFileName() const { return FileName; }
269   const Twine &getMsg() const { return Msg; }
270
271 private:
272   /// Name of the input file associated with this diagnostic.
273   const char *FileName;
274
275   /// Message to report.
276   const Twine &Msg;
277 };
278
279 /// Common features for diagnostics dealing with optimization remarks.
280 class DiagnosticInfoOptimizationBase : public DiagnosticInfo {
281 public:
282   /// \p PassName is the name of the pass emitting this diagnostic.
283   /// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
284   /// the location information to use in the diagnostic. If line table
285   /// information is available, the diagnostic will include the source code
286   /// location. \p Msg is the message to show. Note that this class does not
287   /// copy this message, so this reference must be valid for the whole life time
288   /// of the diagnostic.
289   DiagnosticInfoOptimizationBase(enum DiagnosticKind Kind,
290                                  enum DiagnosticSeverity Severity,
291                                  const char *PassName, const Function &Fn,
292                                  const DebugLoc &DLoc, const Twine &Msg)
293       : DiagnosticInfo(Kind, Severity), PassName(PassName), Fn(Fn), DLoc(DLoc),
294         Msg(Msg) {}
295
296   /// \see DiagnosticInfo::print.
297   void print(DiagnosticPrinter &DP) const override;
298
299   /// Return true if this optimization remark is enabled by one of
300   /// of the LLVM command line flags (-pass-remarks, -pass-remarks-missed,
301   /// or -pass-remarks-analysis). Note that this only handles the LLVM
302   /// flags. We cannot access Clang flags from here (they are handled
303   /// in BackendConsumer::OptimizationRemarkHandler).
304   virtual bool isEnabled() const = 0;
305
306   /// Return true if location information is available for this diagnostic.
307   bool isLocationAvailable() const;
308
309   /// Return a string with the location information for this diagnostic
310   /// in the format "file:line:col". If location information is not available,
311   /// it returns "<unknown>:0:0".
312   const std::string getLocationStr() const;
313
314   /// Return location information for this diagnostic in three parts:
315   /// the source file name, line number and column.
316   void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const;
317
318   const char *getPassName() const { return PassName; }
319   const Function &getFunction() const { return Fn; }
320   const DebugLoc &getDebugLoc() const { return DLoc; }
321   const Twine &getMsg() const { return Msg; }
322
323 private:
324   /// Name of the pass that triggers this report. If this matches the
325   /// regular expression given in -Rpass=regexp, then the remark will
326   /// be emitted.
327   const char *PassName;
328
329   /// Function where this diagnostic is triggered.
330   const Function &Fn;
331
332   /// Debug location where this diagnostic is triggered.
333   DebugLoc DLoc;
334
335   /// Message to report.
336   const Twine &Msg;
337 };
338
339 /// Diagnostic information for applied optimization remarks.
340 class DiagnosticInfoOptimizationRemark : public DiagnosticInfoOptimizationBase {
341 public:
342   /// \p PassName is the name of the pass emitting this diagnostic. If
343   /// this name matches the regular expression given in -Rpass=, then the
344   /// diagnostic will be emitted. \p Fn is the function where the diagnostic
345   /// is being emitted. \p DLoc is the location information to use in the
346   /// diagnostic. If line table information is available, the diagnostic
347   /// will include the source code location. \p Msg is the message to show.
348   /// Note that this class does not copy this message, so this reference
349   /// must be valid for the whole life time of the diagnostic.
350   DiagnosticInfoOptimizationRemark(const char *PassName, const Function &Fn,
351                                    const DebugLoc &DLoc, const Twine &Msg)
352       : DiagnosticInfoOptimizationBase(DK_OptimizationRemark, DS_Remark,
353                                        PassName, Fn, DLoc, Msg) {}
354
355   static bool classof(const DiagnosticInfo *DI) {
356     return DI->getKind() == DK_OptimizationRemark;
357   }
358
359   /// \see DiagnosticInfoOptimizationBase::isEnabled.
360   bool isEnabled() const override;
361 };
362
363 /// Diagnostic information for missed-optimization remarks.
364 class DiagnosticInfoOptimizationRemarkMissed
365     : public DiagnosticInfoOptimizationBase {
366 public:
367   /// \p PassName is the name of the pass emitting this diagnostic. If
368   /// this name matches the regular expression given in -Rpass-missed=, then the
369   /// diagnostic will be emitted. \p Fn is the function where the diagnostic
370   /// is being emitted. \p DLoc is the location information to use in the
371   /// diagnostic. If line table information is available, the diagnostic
372   /// will include the source code location. \p Msg is the message to show.
373   /// Note that this class does not copy this message, so this reference
374   /// must be valid for the whole life time of the diagnostic.
375   DiagnosticInfoOptimizationRemarkMissed(const char *PassName,
376                                          const Function &Fn,
377                                          const DebugLoc &DLoc, const Twine &Msg)
378       : DiagnosticInfoOptimizationBase(DK_OptimizationRemarkMissed, DS_Remark,
379                                        PassName, Fn, DLoc, Msg) {}
380
381   static bool classof(const DiagnosticInfo *DI) {
382     return DI->getKind() == DK_OptimizationRemarkMissed;
383   }
384
385   /// \see DiagnosticInfoOptimizationBase::isEnabled.
386   bool isEnabled() const override;
387 };
388
389 /// Diagnostic information for optimization analysis remarks.
390 class DiagnosticInfoOptimizationRemarkAnalysis
391     : public DiagnosticInfoOptimizationBase {
392 public:
393   /// \p PassName is the name of the pass emitting this diagnostic. If
394   /// this name matches the regular expression given in -Rpass-analysis=, then
395   /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
396   /// is being emitted. \p DLoc is the location information to use in the
397   /// diagnostic. If line table information is available, the diagnostic will
398   /// include the source code location. \p Msg is the message to show. Note that
399   /// this class does not copy this message, so this reference must be valid for
400   /// the whole life time of the diagnostic.
401   DiagnosticInfoOptimizationRemarkAnalysis(const char *PassName,
402                                            const Function &Fn,
403                                            const DebugLoc &DLoc,
404                                            const Twine &Msg)
405       : DiagnosticInfoOptimizationBase(DK_OptimizationRemarkAnalysis, DS_Remark,
406                                        PassName, Fn, DLoc, Msg) {}
407
408   static bool classof(const DiagnosticInfo *DI) {
409     return DI->getKind() == DK_OptimizationRemarkAnalysis;
410   }
411
412   /// \see DiagnosticInfoOptimizationBase::isEnabled.
413   bool isEnabled() const override;
414
415 protected:
416   DiagnosticInfoOptimizationRemarkAnalysis(enum DiagnosticKind Kind,
417                                            const char *PassName,
418                                            const Function &Fn,
419                                            const DebugLoc &DLoc,
420                                            const Twine &Msg)
421       : DiagnosticInfoOptimizationBase(Kind, DS_Remark, PassName, Fn, DLoc,
422                                        Msg) {}
423 };
424
425 /// Diagnostic information for optimization analysis remarks related to
426 /// floating-point non-commutativity.
427 class DiagnosticInfoOptimizationRemarkAnalysisFPCommute
428     : public DiagnosticInfoOptimizationRemarkAnalysis {
429 public:
430   /// \p PassName is the name of the pass emitting this diagnostic. If
431   /// this name matches the regular expression given in -Rpass-analysis=, then
432   /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
433   /// is being emitted. \p DLoc is the location information to use in the
434   /// diagnostic. If line table information is available, the diagnostic will
435   /// include the source code location. \p Msg is the message to show. The
436   /// front-end will append its own message related to options that address
437   /// floating-point non-commutativity. Note that this class does not copy this
438   /// message, so this reference must be valid for the whole life time of the
439   /// diagnostic.
440   DiagnosticInfoOptimizationRemarkAnalysisFPCommute(const char *PassName,
441                                                     const Function &Fn,
442                                                     const DebugLoc &DLoc,
443                                                     const Twine &Msg)
444       : DiagnosticInfoOptimizationRemarkAnalysis(
445             DK_OptimizationRemarkAnalysisFPCommute, PassName, Fn, DLoc, Msg) {}
446
447   static bool classof(const DiagnosticInfo *DI) {
448     return DI->getKind() == DK_OptimizationRemarkAnalysisFPCommute;
449   }
450 };
451
452 /// Diagnostic information for optimization analysis remarks related to
453 /// pointer aliasing.
454 class DiagnosticInfoOptimizationRemarkAnalysisAliasing
455     : public DiagnosticInfoOptimizationRemarkAnalysis {
456 public:
457   /// \p PassName is the name of the pass emitting this diagnostic. If
458   /// this name matches the regular expression given in -Rpass-analysis=, then
459   /// the diagnostic will be emitted. \p Fn is the function where the diagnostic
460   /// is being emitted. \p DLoc is the location information to use in the
461   /// diagnostic. If line table information is available, the diagnostic will
462   /// include the source code location. \p Msg is the message to show. The
463   /// front-end will append its own message related to options that address
464   /// pointer aliasing legality. Note that this class does not copy this
465   /// message, so this reference must be valid for the whole life time of the
466   /// diagnostic.
467   DiagnosticInfoOptimizationRemarkAnalysisAliasing(const char *PassName,
468                                                    const Function &Fn,
469                                                    const DebugLoc &DLoc,
470                                                    const Twine &Msg)
471       : DiagnosticInfoOptimizationRemarkAnalysis(
472             DK_OptimizationRemarkAnalysisAliasing, PassName, Fn, DLoc, Msg) {}
473
474   static bool classof(const DiagnosticInfo *DI) {
475     return DI->getKind() == DK_OptimizationRemarkAnalysisAliasing;
476   }
477 };
478
479 /// Diagnostic information for machine IR parser.
480 class DiagnosticInfoMIRParser : public DiagnosticInfo {
481   const SMDiagnostic &Diagnostic;
482
483 public:
484   DiagnosticInfoMIRParser(DiagnosticSeverity Severity,
485                           const SMDiagnostic &Diagnostic)
486       : DiagnosticInfo(DK_MIRParser, Severity), Diagnostic(Diagnostic) {}
487
488   const SMDiagnostic &getDiagnostic() const { return Diagnostic; }
489
490   void print(DiagnosticPrinter &DP) const override;
491
492   static bool classof(const DiagnosticInfo *DI) {
493     return DI->getKind() == DK_MIRParser;
494   }
495 };
496
497 // Create wrappers for C Binding types (see CBindingWrapping.h).
498 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DiagnosticInfo, LLVMDiagnosticInfoRef)
499
500 /// Emit an optimization-applied message. \p PassName is the name of the pass
501 /// emitting the message. If -Rpass= is given and \p PassName matches the
502 /// regular expression in -Rpass, then the remark will be emitted. \p Fn is
503 /// the function triggering the remark, \p DLoc is the debug location where
504 /// the diagnostic is generated. \p Msg is the message string to use.
505 void emitOptimizationRemark(LLVMContext &Ctx, const char *PassName,
506                             const Function &Fn, const DebugLoc &DLoc,
507                             const Twine &Msg);
508
509 /// Emit an optimization-missed message. \p PassName is the name of the
510 /// pass emitting the message. If -Rpass-missed= is given and \p PassName
511 /// matches the regular expression in -Rpass, then the remark will be
512 /// emitted. \p Fn is the function triggering the remark, \p DLoc is the
513 /// debug location where the diagnostic is generated. \p Msg is the
514 /// message string to use.
515 void emitOptimizationRemarkMissed(LLVMContext &Ctx, const char *PassName,
516                                   const Function &Fn, const DebugLoc &DLoc,
517                                   const Twine &Msg);
518
519 /// Emit an optimization analysis remark message. \p PassName is the name of
520 /// the pass emitting the message. If -Rpass-analysis= is given and \p
521 /// PassName matches the regular expression in -Rpass, then the remark will be
522 /// emitted. \p Fn is the function triggering the remark, \p DLoc is the debug
523 /// location where the diagnostic is generated. \p Msg is the message string
524 /// to use.
525 void emitOptimizationRemarkAnalysis(LLVMContext &Ctx, const char *PassName,
526                                     const Function &Fn, const DebugLoc &DLoc,
527                                     const Twine &Msg);
528
529 /// Emit an optimization analysis remark related to messages about
530 /// floating-point non-commutativity. \p PassName is the name of the pass
531 /// emitting the message. If -Rpass-analysis= is given and \p PassName matches
532 /// the regular expression in -Rpass, then the remark will be emitted. \p Fn is
533 /// the function triggering the remark, \p DLoc is the debug location where the
534 /// diagnostic is generated. \p Msg is the message string to use.
535 void emitOptimizationRemarkAnalysisFPCommute(LLVMContext &Ctx,
536                                              const char *PassName,
537                                              const Function &Fn,
538                                              const DebugLoc &DLoc,
539                                              const Twine &Msg);
540
541 /// Emit an optimization analysis remark related to messages about
542 /// pointer aliasing. \p PassName is the name of the pass emitting the message.
543 /// If -Rpass-analysis= is given and \p PassName matches the regular expression
544 /// in -Rpass, then the remark will be emitted. \p Fn is the function triggering
545 /// the remark, \p DLoc is the debug location where the diagnostic is generated.
546 /// \p Msg is the message string to use.
547 void emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx,
548                                             const char *PassName,
549                                             const Function &Fn,
550                                             const DebugLoc &DLoc,
551                                             const Twine &Msg);
552
553 /// Diagnostic information for optimization failures.
554 class DiagnosticInfoOptimizationFailure
555     : public DiagnosticInfoOptimizationBase {
556 public:
557   /// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
558   /// the location information to use in the diagnostic. If line table
559   /// information is available, the diagnostic will include the source code
560   /// location. \p Msg is the message to show. Note that this class does not
561   /// copy this message, so this reference must be valid for the whole life time
562   /// of the diagnostic.
563   DiagnosticInfoOptimizationFailure(const Function &Fn, const DebugLoc &DLoc,
564                                     const Twine &Msg)
565       : DiagnosticInfoOptimizationBase(DK_OptimizationFailure, DS_Warning,
566                                        nullptr, Fn, DLoc, Msg) {}
567
568   static bool classof(const DiagnosticInfo *DI) {
569     return DI->getKind() == DK_OptimizationFailure;
570   }
571
572   /// \see DiagnosticInfoOptimizationBase::isEnabled.
573   bool isEnabled() const override;
574 };
575
576 /// Emit a warning when loop vectorization is specified but fails. \p Fn is the
577 /// function triggering the warning, \p DLoc is the debug location where the
578 /// diagnostic is generated. \p Msg is the message string to use.
579 void emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn,
580                               const DebugLoc &DLoc, const Twine &Msg);
581
582 /// Emit a warning when loop interleaving is specified but fails. \p Fn is the
583 /// function triggering the warning, \p DLoc is the debug location where the
584 /// diagnostic is generated. \p Msg is the message string to use.
585 void emitLoopInterleaveWarning(LLVMContext &Ctx, const Function &Fn,
586                                const DebugLoc &DLoc, const Twine &Msg);
587
588 } // End namespace llvm
589
590 #endif