47 return ++PluginKindID;
70 if (
const MDNode *SrcLoc =
I.getMetadata(
"srcloc")) {
71 if (SrcLoc->getNumOperands() != 0)
73 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
74 LocCookie = CI->getZExtValue();
110 Fn(Fn), ResourceName(ResourceName), ResourceSize(ResourceSize),
111 ResourceLimit(ResourceLimit) {}
130 if (!FileName.
empty()) {
145void DiagnosticInfo::anchor() {}
146void DiagnosticInfoStackSize::anchor() {}
147void DiagnosticInfoWithLocationBase::anchor() {}
148void DiagnosticInfoIROptimization::anchor() {}
153 File =
DL->getFile();
154 Line =
DL->getLine();
155 Column =
DL->getColumn();
162 File = SP->getFile();
163 Line = SP->getScopeLine();
174 return std::string(
Name);
187 unsigned &Column)
const {
199 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
205 if (
auto *
F = dyn_cast<Function>(V)) {
209 else if (
auto *
I = dyn_cast<Instruction>(V))
210 Loc =
I->getDebugLoc();
214 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
216 else if (isa<Constant>(V)) {
218 V->printAsOperand(
OS,
false);
219 }
else if (
auto *
II = dyn_cast<IntrinsicInst>(V)) {
221 OS <<
"call " <<
II->getCalledFunction()->getName();
222 }
else if (
auto *
I = dyn_cast<Instruction>(V)) {
223 Val =
I->getOpcodeName();
224 }
else if (
auto *MD = dyn_cast<MetadataAsValue>(V)) {
225 if (
auto *S = dyn_cast<MDString>(MD->getMetadata()))
226 Val = S->getString();
259 unsigned long long N)
282 Val =
"<UNKNOWN LOCATION>";
289 DP <<
" (hotness: " << *
Hotness <<
")";
308 return Func->empty() ? nullptr : &Func->front();
329 *CodeRegion->
getParent(), Loc, CodeRegion) {}
357 *CodeRegion->
getParent(), Loc, CodeRegion) {}
371 *CodeRegion->
getParent(), Loc, CodeRegion) {}
399 RemarkName, *CodeRegion->
getParent(), Loc,
422 DP <<
"Instruction selection used fallback path for " <<
getFunction();
426 Args.emplace_back(S);
430 Args.push_back(std::move(
A));
463void OptimizationRemarkAnalysisFPCommute::anchor() {}
464void OptimizationRemarkAnalysisAliasing::anchor() {}
473 for (
int i = 0; i != 2; ++i) {
474 auto AttrName = i == 0 ?
"dontcall-error" :
"dontcall-warn";
477 if (
F->hasFnAttribute(AttrName)) {
479 auto A =
F->getFnAttribute(AttrName);
482 mdconst::extract<ConstantInt>(MD->getOperand(0))->getZExtValue();
485 F->getContext().diagnose(
D);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
static const BasicBlock * getFirstFunctionBlock(const Function *Func)
Module.h This file contains the declarations for the Module class.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
uint64_t IntrinsicInst * II
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
static const char PassName[]
LLVM Basic Block Representation.
Value * getCalledOperand() const
This class represents a function call, abstracting a target machine's calling convention.
StringRef getFilename() const
StringRef getDirectory() const
Subprogram description. Uses SubclassData1.
StringRef getNote() 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
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
Common features for diagnostics dealing with optimization remarks that are used by IR passes.
const Function & getFunction() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
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
void print(DiagnosticPrinter &DP) const override
uint64_t getLocCookie() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
const Twine & getMsg() const
void print(DiagnosticPrinter &DP) const override
DiagnosticInfoMisExpect(const Instruction *Inst, const Twine &Msg LLVM_LIFETIME_BOUND)
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, CamelCase).
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.
bool isEnabled() const override
DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Fn is the function where the diagnostic is being emitted.
const char * getFileName() const
void print(DiagnosticPrinter &DP) const override
const Twine & getMsg() const
DiagnosticInfoRegAllocFailure(const Twine &MsgStr, const Function &Fn, const DiagnosticLocation &DL, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
void print(DiagnosticPrinter &DP) const override
const Function & getFunction() const
void print(DiagnosticPrinter &DP) const override
const char * getResourceName() const
uint64_t getResourceLimit() const
uint64_t getResourceSize() const
DiagnosticInfoResourceLimit(const Function &Fn, const char *ResourceName, uint64_t ResourceSize, uint64_t ResourceLimit, DiagnosticSeverity Severity=DS_Warning, DiagnosticKind Kind=DK_ResourceLimit)
The function that is concerned by this stack size diagnostic.
void print(DiagnosticPrinter &DP) const override
unsigned getLineNum() const
StringRef getFileName() const
const Twine & getMsg() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
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
This is the base abstract class for diagnostic reporting in the backend.
DiagnosticSeverity getSeverity() 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
DiagnosticLocation()=default
Interface for custom diagnostic printing.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
This is an important class for using LLVM in a threaded context.
LLVM_ABI const DiagnosticHandler * getDiagHandlerPtr() const
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to an std::string.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
LLVM_ABI bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_OptimizationRemarkAnalysis
@ DK_OptimizationRemarkMissed
const char * to_string(ThinOrFullLTOPhase Phase)
LLVM_ABI int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
DEMANGLE_ABI std::string demangle(std::string_view MangledName)
Attempt to demangle a string using different demangling schemes.
Implement std::hash so that hash_code can be used in STL containers.
virtual bool isPassedOptRemarkEnabled(StringRef PassName) const
Return true if passed optimization remarks are enabled, override to provide different implementation.
virtual bool isAnalysisRemarkEnabled(StringRef PassName) const
Return true if analysis remarks are enabled, override to provide different implementation.
virtual bool isMissedOptRemarkEnabled(StringRef PassName) const
Return true if missed optimization remarks are enabled, override to provide different implementation.
Used in the streaming interface as the general argument type.
Argument(StringRef Str="")
Used to set IsVerbose via the stream interface.