48 return ++PluginKindID;
58 if (SrcLoc->getNumOperands() != 0)
60 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
61 LocCookie = CI->getZExtValue();
72 DP << getResourceName() <<
" limit";
74 if (getResourceLimit() != 0)
75 DP <<
" of " << getResourceLimit();
77 DP <<
" exceeded (" << getResourceSize() <<
") in " <<
getFunction();
81 DP <<
"ignoring debug info with an invalid version (" << getMetadataVersion()
82 <<
") in " << getModule();
87 DP <<
"ignoring invalid debug info in " << getModule().getModuleIdentifier();
91 if (!FileName.empty()) {
94 DP <<
":" << getLineNum();
109 Filename = DL->getFilename();
110 Line = DL->getLine();
111 Column = DL->getColumn();
118 Line = SP->getScopeLine();
124 unsigned *Column)
const {
125 *Filename = Loc.getFilename();
126 *Line = Loc.getLine();
127 *Column = Loc.getColumn();
134 if (isLocationAvailable())
136 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
141 if (
auto *
F = dyn_cast<Function>(V)) {
145 else if (
auto *
I = dyn_cast<Instruction>(V))
146 Loc =
I->getDebugLoc();
150 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
152 else if (isa<Constant>(V)) {
155 }
else if (
auto *
I = dyn_cast<Instruction>(V))
156 Val =
I->getOpcodeName();
166 : Key(Key),
Val(S.str()) {}
188 unsigned long long N)
192 : Key(Key), Loc(Loc) {
197 Val =
"<UNKNOWN LOCATION>";
204 DP <<
" (hotness: " << *
Hotness <<
")";
210 const Value *CodeRegion)
220 Inst->getDebugLoc(), Inst->
getParent()) {}
225 assert(!Func->
empty() &&
"Function does not have a body");
226 return Func->
front();
244 const Value *CodeRegion)
253 PassName, RemarkName,
255 Inst->getDebugLoc(), Inst->
getParent()) {}
265 const Value *CodeRegion)
274 PassName, RemarkName,
276 Inst->getDebugLoc(), Inst->
getParent()) {}
298 const Value *CodeRegion)
319 DP <<
"Instruction selection used fallback path for " <<
getFunction();
323 Args.emplace_back(S);
327 Args.push_back(std::move(A));
352 void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
354 assert(io.outputting() &&
"input not yet implemented");
356 if (io.mapTag(
"!Passed",
370 else if (io.mapTag(
"!AnalysisFPCommute",
374 else if (io.mapTag(
"!AnalysisAliasing",
389 io.mapRequired(
"Pass", PassName);
391 if (!io.outputting() || DL.
isValid())
392 io.mapOptional(
"DebugLoc", DL);
393 io.mapRequired(
"Function", FN);
394 io.mapOptional(
"Hotness", OptDiag->
Hotness);
395 io.mapOptional(
"Args", OptDiag->
Args);
400 assert(io.outputting() &&
"input not yet implemented");
406 io.mapRequired(
"File", File);
407 io.mapRequired(
"Line", Line);
408 io.mapRequired(
"Column", Col);
411 static const bool flow =
true;
417 assert(io.outputting() &&
"input not yet implemented");
418 io.mapRequired(A.
Key.data(), A.
Val);
420 io.mapOptional(
"DebugLoc", A.
Loc);
const char * PassName
Name of the pass that triggers this report.
static void mapping(IO &io, DiagnosticInfoOptimizationBase::Argument &A)
DiagnosticKind
Defines the different supported kind of a diagnostic.
This class represents an incoming formal argument to a Function.
Compute iterated dominance frontiers using a linear time algorithm.
DiagnosticInfoInlineAsm(const Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Used to set IsVerbose via the stream interface.
void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const
Return location information for this diagnostic in three parts: the source file name, line number and column.
DiagnosticLocation()=default
int FirstExtraArgIndex
If positive, the index of the first argument that only appear in the optimization records and not in ...
const Twine & getMsgStr() const
DiagnosticLocation getLocation() const
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Interface for custom diagnostic printing.
StringRef getFilename() const
bool isEnabled() const override
std::string itostr(int64_t X)
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
StringRef RemarkName
Textual identifier for the remark (single-word, camel-case).
static Function * getFunction(Constant *C)
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
SmallVector< Argument, 4 > Args
Arguments collected via the streaming interface.
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
This is the base abstract class for diagnostic reporting in the backend.
const Function & getFunction() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Common features for diagnostics dealing with optimization remarks that are used by IR passes...
static const BasicBlock & getFirstFunctionBlock(const Function *Func)
unsigned getLocCookie() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Used in the streaming interface as the general argument type.
virtual bool isMissedOptRemarkEnabled(StringRef PassName) const
Return true if missed optimization remarks are enabled, override to provide different implementation...
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&... Args)
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.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void mapping(IO &io, DiagnosticLocation &DL)
bool IsVerbose
The remark is expected to be noisy.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
std::string getMsg() const
virtual bool isPassedOptRemarkEnabled(StringRef PassName) const
Return true if passed optimization remarks are enabled, override to provide different implementation...
Module.h This file contains the declarations for the Module class.
std::string utostr(uint64_t X, bool isNeg=false)
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', drop it.
int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
void print(DiagnosticPrinter &DP) const override
amdgpu Simplify well known AMD library false Value Value * Arg
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
virtual bool isAnalysisRemarkEnabled(StringRef PassName) const
Return true if analysis remarks are enabled, override to provide different implementation.
void print(DiagnosticPrinter &DP) const override
StringRef getName() const
Return a constant reference to the value's name.
DiagnosticSeverity getSeverity() const
void print(DiagnosticPrinter &DP) const override
const std::string to_string(const T &Value)
const DiagnosticHandler * getDiagHandlerPtr() const
getDiagHandlerPtr - Returns const raw pointer of DiagnosticHandler set by setDiagnosticHandler.
static MemoryLocation getLocation(Instruction *I, AliasAnalysis *AA)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
A raw_ostream that writes to an std::string.
LLVM Value Representation.
Optional< uint64_t > Hotness
If profile information is available, this is the number of times the corresponding code was executed ...
static const Function * getParent(const Value *V)
void print(DiagnosticPrinter &DP) const override
const std::string getLocationStr() const
Return a string with the location information for this diagnostic in the format "file:line:col".
Argument(StringRef Str="")
StringRef - Represent a constant reference to a string, i.e.
void print(DiagnosticPrinter &DP) const override
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
unsigned getColumn() const
StringRef getFilename() const
StringRef getPassName() const
DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Fn is the function where the diagnostic is being emitted.