46 return ++PluginKindID;
55 if (
const MDNode *SrcLoc =
I.getMetadata(
"srcloc")) {
56 if (SrcLoc->getNumOperands() != 0)
58 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
59 LocCookie = CI->getZExtValue();
73 Fn(Fn), ResourceName(ResourceName), ResourceSize(ResourceSize),
74 ResourceLimit(ResourceLimit) {}
93 if (!FileName.
empty()) {
108void DiagnosticInfo::anchor() {}
109void DiagnosticInfoStackSize::anchor() {}
110void DiagnosticInfoWithLocationBase::anchor() {}
111void DiagnosticInfoIROptimization::anchor() {}
116 File =
DL->getFile();
117 Line =
DL->getLine();
118 Column =
DL->getColumn();
126 Line = SP->getScopeLine();
137 return std::string(
Name);
150 unsigned &Column)
const {
162 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
168 if (
auto *
F = dyn_cast<Function>(V)) {
172 else if (
auto *
I = dyn_cast<Instruction>(V))
173 Loc =
I->getDebugLoc();
177 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
179 else if (isa<Constant>(V)) {
181 V->printAsOperand(
OS,
false);
182 }
else if (
auto *
I = dyn_cast<Instruction>(V)) {
183 Val =
I->getOpcodeName();
184 }
else if (
auto *MD = dyn_cast<MetadataAsValue>(V)) {
185 if (
auto *S = dyn_cast<MDString>(MD->getMetadata()))
186 Val = S->getString();
219 unsigned long long N)
242 Val =
"<UNKNOWN LOCATION>";
249 DP <<
" (hotness: " << *
Hotness <<
")";
255 const Value *CodeRegion)
268 return Func->empty() ? nullptr : &Func->front();
286 const Value *CodeRegion)
314 const Value *CodeRegion)
358 const Value *CodeRegion)
379 DP <<
"Instruction selection used fallback path for " <<
getFunction();
383 Args.emplace_back(S);
387 Args.push_back(std::move(
A));
420void OptimizationRemarkAnalysisFPCommute::anchor() {}
421void OptimizationRemarkAnalysisAliasing::anchor() {}
430 for (
int i = 0; i != 2; ++i) {
431 auto AttrName = i == 0 ?
"dontcall-error" :
"dontcall-warn";
434 if (
F->hasFnAttribute(AttrName)) {
436 auto A =
F->getFnAttribute(AttrName);
439 mdconst::extract<ConstantInt>(MD->getOperand(0))->getZExtValue();
442 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)
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.
Module.h This file contains the declarations for the Module class.
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
StringRef getNote() 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 Function & getFunction() const
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
DiagnosticInfoInlineAsm(const Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
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.
const Twine & getMsg() const
void print(DiagnosticPrinter &DP) const override
DiagnosticInfoMisExpect(const Instruction *Inst, Twine &Msg)
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.
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
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
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.
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.
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.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
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.
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
StringRef remove_leading_dotslash(StringRef path, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
This is an optimization pass for GlobalISel generic memory operations.
std::string to_string(const T &Value)
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
int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.