14#ifndef LLVM_IR_DIAGNOSTICINFO_H
15#define LLVM_IR_DIAGNOSTICINFO_H
37class DiagnosticPrinter;
115 virtual void anchor();
118 : Kind(Kind), Severity(Severity) {}
191 unsigned MetadataVersion;
199 MetadataVersion(MetadataVersion) {}
241 LineNum(LineNum), Msg(Msg) {}
267 unsigned LineNum = 0;
292 const char *FileName;
319 void anchor()
override;
340 unsigned &Column)
const;
364 const char *ResourceName;
394 void anchor()
override;
466 void insert(setIsVerbose V);
467 void insert(setExtraArgs EA);
481 std::string
getMsg()
const;
541template <
class RemarkT>
545 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
554template <
class RemarkT>
558 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
565template <
class RemarkT>
569 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
576template <
class RemarkT>
580 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
587template <
class RemarkT>
591 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
598template <
class RemarkT>
602 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
609template <
class RemarkT>
613 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
623 void anchor()
override;
638 const Value *CodeRegion =
nullptr)
641 CodeRegion(CodeRegion) {}
657 std::copy(Orig.
Args.begin(), Orig.
Args.end(), std::back_inserter(
Args));
685 const Value *CodeRegion =
nullptr;
744 const Value *CodeRegion);
790 const Value *CodeRegion);
833 const Value *CodeRegion);
854 void anchor()
override;
866 const Value *CodeRegion)
896 void anchor()
override;
907 const Value *CodeRegion)
988 nullptr, Fn, Loc, Msg) {}
997 const Value *CodeRegion);
1004 bool isEnabled()
const override;
1083 bool InlineAsmDiag =
true,
uint64_t LocCookie = 0)
1085 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1086 LocCookie(LocCookie) {}
1110 LocCookie(LocCookie) {}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Machine Check Debug Module
This file defines the SmallVector class.
static const char PassName[]
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef getNote() const
DiagnosticInfoDontCall(StringRef CalleeName, StringRef Note, DiagnosticSeverity DS, uint64_t LocCookie)
static bool classof(const DiagnosticInfo *DI)
uint64_t getLocCookie() const
StringRef getFunctionName() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
Common features for diagnostics dealing with optimization remarks that are used by IR passes.
const Value * getCodeRegion() const
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 Value *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.
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for ISel fallback path.
static bool classof(const DiagnosticInfo *DI)
const Function & getFunction() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
DiagnosticInfoISelFallback(const Function &Fn, DiagnosticSeverity Severity=DS_Warning)
Diagnostic information for inline asm reporting.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoInlineAsm(uint64_t LocCookie, const Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
LocCookie if non-zero gives the line number for this report.
DiagnosticInfoInlineAsm(const Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
const Instruction * getInstruction() const
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
uint64_t getLocCookie() const
Diagnostic information for machine IR parser.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
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
void print(DiagnosticPrinter &DP) const override
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
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 getPassName() const
StringRef RemarkName
Textual identifier for the remark (single-word, camel-case).
std::string getMsg() const
void print(DiagnosticPrinter &DP) const override
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.
StringRef getRemarkName() const
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
DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg, DiagnosticSeverity Severity=DS_Error)
static bool classof(const DiagnosticInfo *DI)
void print(DiagnosticPrinter &DP) const override
const Twine & getMsg() const
Diagnostic information for stack size etc.
const Function & getFunction() const
void print(DiagnosticPrinter &DP) const override
const char * getResourceName() const
uint64_t getResourceLimit() const
static bool classof(const DiagnosticInfo *DI)
uint64_t getResourceSize() const
Diagnostic information for the sample profiler.
DiagnosticInfoSampleProfile(StringRef FileName, const Twine &Msg, DiagnosticSeverity Severity=DS_Error)
void print(DiagnosticPrinter &DP) const override
static bool classof(const DiagnosticInfo *DI)
unsigned getLineNum() const
DiagnosticInfoSampleProfile(StringRef FileName, unsigned LineNum, const Twine &Msg, DiagnosticSeverity Severity=DS_Error)
DiagnosticInfoSampleProfile(const Twine &Msg, DiagnosticSeverity Severity=DS_Error)
StringRef getFileName() const
const Twine & getMsg() const
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
bool isInlineAsmDiag() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
StringRef getModuleName() const
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoStackSize(const Function &Fn, uint64_t StackSize, uint64_t StackLimit, DiagnosticSeverity Severity=DS_Warning)
uint64_t getStackLimit() const
uint64_t getStackSize() const
Diagnostic information for unsupported feature in backend.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
const Twine & getMessage() const
DiagnosticInfoUnsupported(const Function &Fn, const Twine &Msg, 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.
std::string getLocationStr() const
Return a string with the location information for this diagnostic in the format "file:line:col".
std::string getAbsolutePath() const
Return the absolute path tot the file.
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.
std::string getAbsolutePath() const
Return the full path to the file.
StringRef getRelativePath() const
Return the file name relative to the compilation directory.
unsigned getColumn() const
DiagnosticLocation()=default
Interface for custom diagnostic printing.
A Module instance is used to store all the information related to an LLVM module.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
struct LLVMOpaqueDiagnosticInfo * LLVMDiagnosticInfoRef
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
void diagnoseDontCall(const CallInst &CI)
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_DebugMetadataInvalid
@ DK_OptimizationRemarkAnalysis
@ DK_OptimizationRemarkAnalysisAliasing
@ DK_MachineOptimizationRemark
@ DK_OptimizationRemarkMissed
@ DK_MachineOptimizationRemarkAnalysis
@ DK_MachineOptimizationRemarkMissed
@ DK_DebugMetadataVersion
@ DK_OptimizationRemarkAnalysisFPCommute
int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
static DiagnosticSeverity getDiagnosticSeverity(SourceMgr::DiagKind DK)
std::function< void(const DiagnosticInfo &)> DiagnosticHandlerFunction
Used in the streaming interface as the general argument type.
Argument(StringRef Str="")
Argument(StringRef Key, const char *S)
Argument(StringRef Key, bool B)
Used to set IsVerbose via the stream interface.