14#ifndef LLVM_IR_DIAGNOSTICINFO_H
15#define LLVM_IR_DIAGNOSTICINFO_H
39class DiagnosticPrinter;
122 virtual void anchor();
125 : Kind(Kind), Severity(Severity) {}
219 unsigned MetadataVersion;
227 MetadataVersion(MetadataVersion) {}
270 LineNum(LineNum), Msg(Msg) {}
297 unsigned LineNum = 0;
323 const char *FileName;
350 void anchor()
override;
366 std::string getLocationStr()
const;
371 unsigned &Column)
const;
374 std::string getAbsolutePath()
const;
473 const char *ResourceName;
503 void anchor()
override;
576 void insert(setIsVerbose V);
577 void insert(setExtraArgs EA);
591 std::string getMsg()
const;
592 std::optional<uint64_t>
getHotness()
const {
return Hotness; }
640 bool IsVerbose =
false;
645 int FirstExtraArgIndex = -1;
651template <
class RemarkT>
653operator<<(RemarkT &&R,
655 std::remove_reference_t<RemarkT>>,
659 return std::forward<RemarkT>(R);
662template <
class RemarkT>
664operator<<(RemarkT &&R,
666 std::remove_reference_t<RemarkT>>,
670 return std::forward<RemarkT>(R);
673template <
class RemarkT>
675operator<<(RemarkT &&R,
677 std::remove_reference_t<RemarkT>>,
681 return std::forward<RemarkT>(R);
684template <
class RemarkT>
686operator<<(RemarkT &&R,
688 std::remove_reference_t<RemarkT>>,
692 return std::forward<RemarkT>(R);
699 void anchor()
override;
716 CodeRegion(CodeRegion) {}
730 CodeRegion(Orig.getCodeRegion()) {
790 bool isEnabled()
const override;
835 bool isEnabled()
const override;
892 bool isEnabled()
const override;
929 void anchor()
override;
943 PassName, RemarkName, Loc, CodeRegion) {}
972 void anchor()
override;
985 PassName, RemarkName, Loc, CodeRegion) {}
1081 nullptr, Fn, Loc, Msg) {}
1096 bool isEnabled()
const override;
1177 bool InlineAsmDiag =
true,
uint64_t LocCookie = 0)
1179 Diagnostic(Diagnostic), ModName(ModName), InlineAsmDiag(InlineAsmDiag),
1180 LocCookie(LocCookie) {}
1204 LocCookie(LocCookie) {}
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)
#define LLVM_LIFETIME_BOUND
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
Subprogram description. Uses SubclassData1.
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
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 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 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
uint64_t getLocCookie() 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)
const Twine & getMsgStr() const
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 getPassName() const
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.
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
static bool classof(const DiagnosticInfo *DI)
DiagnosticInfoPGOProfile(const char *FileName, const Twine &Msg LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
const Twine & getMsg() const
const Twine & getMsgStr() const
static bool classof(const DiagnosticInfo *DI)
Diagnostic information for stack size etc.
const Function & getFunction() const
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 LLVM_LIFETIME_BOUND, DiagnosticSeverity Severity=DS_Error)
static bool classof(const DiagnosticInfo *DI)
unsigned getLineNum() const
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)
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
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.
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.
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
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...
LLVM_ABI 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.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
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
LLVM_ABI int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
static DiagnosticSeverity getDiagnosticSeverity(SourceMgr::DiagKind DK)
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.