14#ifndef LLVM_IR_DIAGNOSTICINFO_H
15#define LLVM_IR_DIAGNOSTICINFO_H
37class DiagnosticPrinter;
119 virtual void anchor();
122 : Kind(Kind), Severity(Severity) {}
213 unsigned MetadataVersion;
221 MetadataVersion(MetadataVersion) {}
263 LineNum(LineNum), Msg(Msg) {}
289 unsigned LineNum = 0;
314 const char *FileName;
341 void anchor()
override;
362 unsigned &Column)
const;
437 const char *ResourceName;
467 void anchor()
override;
539 void insert(setIsVerbose V);
540 void insert(setExtraArgs EA);
554 std::string
getMsg()
const;
614template <
class RemarkT>
618 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
627template <
class RemarkT>
631 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
638template <
class RemarkT>
642 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
649template <
class RemarkT>
653 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
660template <
class RemarkT>
664 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
671template <
class RemarkT>
675 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
682template <
class RemarkT>
686 std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
696 void anchor()
override;
711 const Value *CodeRegion =
nullptr)
714 CodeRegion(CodeRegion) {}
730 std::copy(Orig.
Args.begin(), Orig.
Args.end(), std::back_inserter(
Args));
758 const Value *CodeRegion =
nullptr;
817 const Value *CodeRegion);
863 const Value *CodeRegion);
906 const Value *CodeRegion);
927 void anchor()
override;
939 const Value *CodeRegion)
969 void anchor()
override;
980 const Value *CodeRegion)
1077 nullptr, Fn, Loc, Msg) {}
1086 const Value *CodeRegion);
1093 bool isEnabled()
const override;
1172 bool InlineAsmDiag =
true,
uint64_t LocCookie = 0)
1174 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1175 LocCookie(LocCookie) {}
1199 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.
void print(DiagnosticPrinter &DP) const override
const Twine & getMsgStr() 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 Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
const Twine & getMsgStr() const
DiagnosticInfoGeneric(const Instruction *I, const Twine &ErrMsg, DiagnosticSeverity Severity=DS_Error)
void print(DiagnosticPrinter &DP) const override
const Instruction * getInstruction() const
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)
const Instruction * getInstruction() const
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
uint64_t getLocCookie() const
Diagnostic information for IR instrumentation reporting.
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoInstrumentation(const Twine &DiagMsg, DiagnosticSeverity Severity=DS_Warning)
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
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
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
static bool classof(const DiagnosticInfo *DI)
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.