48 return ++PluginKindID;
71 if (
const MDNode *SrcLoc =
I.getMetadata(
"srcloc")) {
72 if (SrcLoc->getNumOperands() != 0)
74 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
75 LocCookie = CI->getZExtValue();
111 Fn(Fn), ResourceName(ResourceName), ResourceSize(ResourceSize),
112 ResourceLimit(ResourceLimit) {}
131 if (!FileName.empty()) {
146void DiagnosticInfo::anchor() {}
147void DiagnosticInfoStackSize::anchor() {}
148void DiagnosticInfoWithLocationBase::anchor() {}
149void DiagnosticInfoIROptimization::anchor() {}
154 File =
DL->getFile();
155 Line =
DL->getLine();
156 Column =
DL->getColumn();
163 File = SP->getFile();
164 Line = SP->getScopeLine();
169 return File->getFilename();
175 return std::string(Name);
183 return Loc.getAbsolutePath();
188 unsigned &Column)
const {
189 RelativePath = Loc.getRelativePath();
190 Line = Loc.getLine();
191 Column = Loc.getColumn();
211 Loc =
I->getDebugLoc();
219 V->printAsOperand(OS,
false);
223 Val =
I->getOpcodeName();
226 Val = S->getString();
258 unsigned long long N)
288 Val =
"<UNKNOWN LOCATION>";
295 DP <<
" (hotness: " << *
Hotness <<
")";
314 return Func->empty() ? nullptr : &Func->front();
424 unsigned IntrinsicID,
428 IntrinsicID(IntrinsicID),
429 RequiredFeatures(
Intrinsic::getRequiredTargetFeatures(
431 assert(!RequiredFeatures.empty() &&
432 "intrinsic without required features should be supported");
438 " requires target feature '" + RequiredFeatures +
"'")
457 DP <<
"Instruction selection used fallback path for " <<
getFunction();
461 Args.emplace_back(S);
465 Args.push_back(std::move(
A));
498void OptimizationRemarkAnalysisFPCommute::anchor() {}
499void OptimizationRemarkAnalysisAliasing::anchor() {}
508 for (
int i = 0; i != 2; ++i) {
509 auto AttrName = i == 0 ?
"dontcall-error" :
"dontcall-warn";
512 if (
F->hasFnAttribute(AttrName)) {
514 auto A =
F->getFnAttribute(AttrName);
520 LocCookie, InlinedFromMD);
525 if (
auto *Scope =
Loc->getScope())
526 if (
auto *SP = Scope->getSubprogram())
527 DebugChain.
push_back({SP->getName(),
Loc->getFilename(),
528 Loc->getLine(),
Loc->getColumn()});
532 for (
const DILocation *InlinedAt =
Loc->getInlinedAt(); InlinedAt;
533 InlinedAt = InlinedAt->getInlinedAt())
534 AddLocation(InlinedAt);
536 D.setDebugInlineChain(std::move(DebugChain));
539 F->getContext().diagnose(
D);
560 for (
unsigned I = 0, E = InlinedFromMD->getNumOperands();
I + 1 < E;
I += 2) {
564 if (NameMD && !NameMD->getString().empty())
566 LocMD ? LocMD->getZExtValue() : 0);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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 DebugLoc that has line number information, given a range of instructions.
uint64_t IntrinsicInst * II
static constexpr StringLiteral Filename
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
LLVM Basic Block Representation.
Value * getCalledOperand() const
This class represents a function call, abstracting a target machine's calling convention.
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.
SmallVector< std::pair< StringRef, uint64_t > > getInliningDecisions() const
void print(DiagnosticPrinter &DP) const override
const Twine & getMsgStr() const
const Twine & getMsgStr() const
void print(DiagnosticPrinter &DP) const override
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.
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
uint64_t getResourceLimit() const
const Twine & getResourceName() const
DiagnosticInfoResourceLimit(const Function &Fn, const Twine &ResourceName LLVM_LIFETIME_BOUND, uint64_t ResourceSize, uint64_t ResourceLimit, DiagnosticSeverity Severity=DS_Warning, DiagnosticKind Kind=DK_ResourceLimit)
The function that is concerned by this stack size diagnostic.
uint64_t getResourceSize() const
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.
DiagnosticInfoUnsupportedTargetIntrinsic(const Function &Fn, unsigned IntrinsicID, const DiagnosticLocation &Loc=DiagnosticLocation())
std::string getMessage() 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.
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
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.
DiagnosticLocation()=default
Interface for custom diagnostic printing.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
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 void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
LLVM_ABI StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
std::string utostr(uint64_t X, bool isNeg=false)
DiagnosticKind
Defines the different supported kind of a diagnostic.
@ DK_OptimizationRemarkAnalysis
@ DK_UnsupportedTargetIntrinsic
@ DK_OptimizationRemarkMissed
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
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.
std::string itostr(int64_t X)
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.