49 return ++PluginKindID;
59 if (SrcLoc->getNumOperands() != 0)
61 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
62 LocCookie = CI->getZExtValue();
73 DP << getResourceName() <<
" limit";
75 if (getResourceLimit() != 0)
76 DP <<
" of " << getResourceLimit();
78 DP <<
" exceeded (" << getResourceSize() <<
") in " <<
getFunction();
82 DP <<
"ignoring debug info with an invalid version (" << getMetadataVersion()
83 <<
") in " << getModule();
88 DP <<
"ignoring invalid debug info in " << getModule().getModuleIdentifier();
92 if (!FileName.empty()) {
95 DP <<
":" << getLineNum();
107 void DiagnosticInfo::anchor() {}
108 void DiagnosticInfoStackSize::anchor() {}
109 void DiagnosticInfoWithLocationBase::anchor() {}
110 void DiagnosticInfoIROptimization::anchor() {}
115 File = DL->getFile();
116 Line = DL->getLine();
117 Column = DL->getColumn();
125 Line = SP->getScopeLine();
130 return File->getFilename();
144 return Loc.getAbsolutePath();
149 unsigned &Column)
const {
150 RelativePath = Loc.getRelativePath();
151 Line = Loc.getLine();
152 Column = Loc.getColumn();
159 if (isLocationAvailable())
161 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
166 if (
auto *
F = dyn_cast<Function>(V)) {
170 else if (
auto *
I = dyn_cast<Instruction>(V))
171 Loc =
I->getDebugLoc();
175 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
177 else if (isa<Constant>(V)) {
180 }
else if (
auto *
I = dyn_cast<Instruction>(V))
181 Val =
I->getOpcodeName();
191 : Key(Key),
Val(S.str()) {}
213 unsigned long long N)
217 : Key(Key), Loc(Loc) {
222 Val =
"<UNKNOWN LOCATION>";
229 DP <<
" (hotness: " << *
Hotness <<
")";
235 const Value *CodeRegion)
250 assert(!Func->
empty() &&
"Function does not have a body");
251 return Func->
front();
269 const Value *CodeRegion)
278 PassName, RemarkName,
290 const Value *CodeRegion)
299 PassName, RemarkName,
323 const Value *CodeRegion)
344 DP <<
"Instruction selection used fallback path for " <<
getFunction();
348 Args.emplace_back(S);
352 Args.push_back(std::move(A));
374 void OptimizationRemarkAnalysisFPCommute::anchor() {}
375 void OptimizationRemarkAnalysisAliasing::anchor() {}
380 void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
382 assert(io.outputting() &&
"input not yet implemented");
384 if (io.mapTag(
"!Passed",
398 else if (io.mapTag(
"!AnalysisFPCommute",
402 else if (io.mapTag(
"!AnalysisAliasing",
417 io.mapRequired(
"Pass", PassName);
419 if (!io.outputting() || DL.
isValid())
420 io.mapOptional(
"DebugLoc", DL);
421 io.mapRequired(
"Function", FN);
422 io.mapOptional(
"Hotness", OptDiag->
Hotness);
423 io.mapOptional(
"Args", OptDiag->
Args);
428 assert(io.outputting() &&
"input not yet implemented");
434 io.mapRequired(
"File", File);
435 io.mapRequired(
"Line", Line);
436 io.mapRequired(
"Column", Col);
439 static const bool flow =
true;
445 assert(io.outputting() &&
"input not yet implemented");
446 io.mapRequired(A.
Key.data(), A.
Val);
448 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.
std::string getAbsolutePath() const
Return the absolute path tot the file.
This class represents an incoming formal argument to a Function.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
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.
DiagnosticLocation()=default
int FirstExtraArgIndex
If positive, the index of the first argument that only appear in the optimization records and not in ...
StringRef remove_leading_dotslash(StringRef path, Style style=Style::native)
Remove redundant leading "./" pieces and consecutive separators.
const Twine & getMsgStr() const
DiagnosticLocation getLocation() const
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
Interface for custom diagnostic printing.
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)
void getLocation(StringRef &RelativePath, unsigned &Line, unsigned &Column) const
Return location information for this diagnostic in three parts: the relative source file path...
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.
StringRef getRelativePath() const
Return the file name relative to the compilation directory.
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.
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.
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.
std::string getAbsolutePath() const
Return the full path to the file.
unsigned getColumn() const
StringRef getPassName() const
DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Fn is the function where the diagnostic is being emitted.