51 struct PassRemarksOpt {
52 std::shared_ptr<Regex> Pattern;
54 void operator=(
const std::string &Val) {
57 Pattern = std::make_shared<Regex>(Val);
58 std::string RegexError;
59 if (!Pattern->isValid(RegexError))
61 "' in -pass-remarks: " + RegexError,
77 cl::desc(
"Enable optimization remarks from passes whose name match "
78 "the given regular expression"),
86 cl::desc(
"Enable missed optimization remarks from passes whose name match "
87 "the given regular expression"),
97 "Enable optimization analysis remarks from passes whose name match "
98 "the given regular expression"),
104 return ++PluginKindID;
114 if (SrcLoc->getNumOperands() != 0)
116 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
117 LocCookie = CI->getZExtValue();
147 if (!FileName.
empty()) {
165 Filename = DL->getFilename();
166 Line = DL->getLine();
167 Column = DL->getColumn();
174 Line = SP->getScopeLine();
180 unsigned *Column)
const {
192 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
197 if (
auto *
F = dyn_cast<Function>(V)) {
201 else if (
auto *
I = dyn_cast<Instruction>(V))
202 Loc =
I->getDebugLoc();
206 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
208 else if (isa<Constant>(V)) {
211 }
else if (
auto *
I = dyn_cast<Instruction>(V))
212 Val =
I->getOpcodeName();
222 : Key(Key), Val(
itostr(N)) {}
225 : Key(Key), Val(
utostr(N)) {}
230 DP <<
" (hotness: " << *
Hotness <<
")";
236 const Value *CodeRegion)
246 Inst->getDebugLoc(), Inst->
getParent()) {}
251 assert(!Func->
empty() &&
"Function does not have a body");
252 return Func->
front();
269 const Value *CodeRegion)
278 PassName, RemarkName,
280 Inst->getDebugLoc(), Inst->
getParent()) {}
289 const Value *CodeRegion)
298 PassName, RemarkName,
300 Inst->getDebugLoc(), Inst->
getParent()) {}
333 const char *PassName,
347 const char *PassName,
356 const Value *CodeRegion)
377 DP <<
"Instruction selection used fallback path for " <<
getFunction();
382 Args.emplace_back(S);
388 Args.push_back(std::move(A));
const char * PassName
Name of the pass that triggers this report.
DiagnosticKind
Defines the different supported kind of a diagnostic.
StringRef getFilename() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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...
DiagnosticInfoOptimizationBase & operator<<(StringRef S)
Used to set IsVerbose via the stream interface.
static cl::opt< PassRemarksOpt, true, cl::parser< std::string > > PassRemarks("pass-remarks", cl::value_desc("pattern"), cl::desc("Enable optimization remarks from passes whose name match ""the given regular expression"), cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired, cl::ZeroOrMore)
static PassRemarksOpt PassRemarksAnalysisOptLoc
uint64_t getResourceSize() const
DiagnosticLocation()=default
int FirstExtraArgIndex
If positive, the index of the first argument that only appear in the optimization records and not in ...
void emitOptimizationRemarkAnalysisFPCommute(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface to emit an optimization analysis remark related to messages about floating-point non...
const Function & getFunction() const
StringRef getName() const
Return a constant reference to the value's name.
bool isLocationAvailable() const
Return true if location information is available for this diagnostic.
const std::string getLocationStr() const
Return a string with the location information for this diagnostic in the format "file:line:col".
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getFilename() const
Interface for custom diagnostic printing.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
bool isEnabled() const override
static cl::opt< PassRemarksOpt, true, cl::parser< std::string > > PassRemarksAnalysis("pass-remarks-analysis", cl::value_desc("pattern"), cl::desc("Enable optimization analysis remarks from passes whose name match ""the given regular expression"), cl::Hidden, cl::location(PassRemarksAnalysisOptLoc), cl::ValueRequired, cl::ZeroOrMore)
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.
static std::string utostr(uint64_t X, bool isNeg=false)
DiagnosticSeverity getSeverity() const
StringRef RemarkName
Textual identifier for the remark (single-word, camel-case).
uint64_t getResourceLimit() const
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
const Function & getFunction() const
SmallVector< Argument, 4 > Args
Arguments collected via the streaming interface.
void emitOptimizationRemark(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface to emit an optimization-applied message.
void emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface to emit an optimization analysis remark related to messages about pointer aliasing...
This is the base abstract class for diagnostic reporting in the backend.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
const Twine & getMsg() const
This is an important class for using LLVM in a threaded context.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
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...
const Twine & getMsg() const
const char * getFileName() const
static const BasicBlock & getFirstFunctionBlock(const Function *Func)
unsigned getColumn() const
Used in the streaming interface as the general argument type.
static std::string itostr(int64_t X)
void emitOptimizationRemarkMissed(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface to emit an optimization-missed message.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
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.
DiagnosticLocation getLocation() const
unsigned getLocCookie() const
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
Module.h This file contains the declarations for the Module class.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
static PassRemarksOpt PassRemarksOptLoc
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
unsigned getLineNum() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
int getNextAvailablePluginDiagnosticKind()
Get the next available kind ID for a plugin diagnostic.
void print(DiagnosticPrinter &DP) const override
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
static PassRemarksOpt PassRemarksMissedOptLoc
std::string getMsg() const
const char * getResourceName() const
void print(DiagnosticPrinter &DP) const override
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void print(DiagnosticPrinter &DP) const override
static cl::opt< PassRemarksOpt, true, cl::parser< std::string > > PassRemarksMissed("pass-remarks-missed", cl::value_desc("pattern"), cl::desc("Enable missed optimization remarks from passes whose name match ""the given regular expression"), cl::Hidden, cl::location(PassRemarksMissedOptLoc), cl::ValueRequired, cl::ZeroOrMore)
void emitOptimizationRemarkAnalysis(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Legacy interface to emit an optimization analysis remark message.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
const Twine & getMsgStr() const
A raw_ostream that writes to an std::string.
LLVM Value Representation.
const Function & getFunction() const
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
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
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.
StringRef getFileName() const
LocationClass< Ty > location(Ty &L)
DiagnosticInfoOptimizationFailure(const Function &Fn, const DiagnosticLocation &Loc, const Twine &Msg)
Fn is the function where the diagnostic is being emitted.