40 struct PassRemarksOpt {
41 std::shared_ptr<Regex> Pattern;
43 void operator=(
const std::string &Val) {
46 Pattern = std::make_shared<Regex>(Val);
47 std::string RegexError;
48 if (!Pattern->isValid(RegexError))
50 "' in -pass-remarks: " + RegexError,
56 static PassRemarksOpt PassRemarksOptLoc;
57 static PassRemarksOpt PassRemarksMissedOptLoc;
58 static PassRemarksOpt PassRemarksAnalysisOptLoc;
64 cl::desc(
"Enable optimization remarks from passes whose name match "
65 "the given regular expression"),
73 cl::desc(
"Enable missed optimization remarks from passes whose name match "
74 "the given regular expression"),
84 "Enable optimization analysis remarks from passes whose name match "
85 "the given regular expression"),
92 return ++PluginKindID;
103 if (SrcLoc->getNumOperands() != 0)
105 mdconst::dyn_extract<ConstantInt>(SrcLoc->getOperand(0)))
106 LocCookie = CI->getZExtValue();
136 if (!FileName.
empty()) {
157 unsigned *Column)
const {
159 assert(L !=
nullptr &&
"debug location is invalid");
160 *Filename = L->getFilename();
161 *Line = L->getLine();
162 *Column = L->getColumn();
171 return (Filename +
":" +
Twine(Line) +
":" +
Twine(Column)).str();
176 if (
auto *
F = dyn_cast<Function>(V)) {
180 else if (
auto *
I = dyn_cast<Instruction>(V))
181 DLoc =
I->getDebugLoc();
185 if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
187 else if (isa<Constant>(V)) {
190 }
else if (
auto *
I = dyn_cast<Instruction>(V))
191 Val =
I->getOpcodeName();
201 : Key(Key), Val(
itostr(N)) {}
204 : Key(Key), Val(
utostr(N)) {}
209 DP <<
" (hotness: " << *Hotness <<
")";
224 Inst->getDebugLoc(), Inst->
getParent()) {}
227 return PassRemarksOptLoc.Pattern &&
243 PassName, RemarkName,
245 Inst->getDebugLoc(), Inst->
getParent()) {}
248 return PassRemarksMissedOptLoc.Pattern &&
249 PassRemarksMissedOptLoc.Pattern->match(
getPassName());
264 PassName, RemarkName,
266 Inst->getDebugLoc(), Inst->
getParent()) {}
269 const char *PassName,
279 (PassRemarksAnalysisOptLoc.Pattern &&
280 PassRemarksAnalysisOptLoc.Pattern->match(
getPassName()));
301 const char *PassName,
309 const char *PassName,
317 const char *PassName,
342 Fn, DLoc,
Twine(
"loop not vectorized: " + Msg)));
348 Fn, DLoc,
Twine(
"loop not interleaved: " + Msg)));
352 DP <<
"Instruction selection used fallback path for " <<
getFunction();
357 Args.emplace_back(S);
363 Args.push_back(std::move(A));
375 FirstExtraArgIndex = Args.size();
383 make_range(Args.begin(), FirstExtraArgIndex == -1
385 : Args.begin() + FirstExtraArgIndex))
DiagnosticKind
Defines the different supported kind of a diagnostic.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
const Function & getFunction() const
bool isLocationAvailable() const
Return true if location information is available for this diagnostic.
DiagnosticInfoInlineAsm(const Twine &MsgStr, DiagnosticSeverity Severity=DS_Error)
MsgStr is the message to be reported to the frontend.
DiagnosticInfoOptimizationBase & operator<<(StringRef S)
Used to set IsVerbose via the stream interface.
uint64_t getResourceSize() const
const DebugLoc & getDebugLoc() const
void emitOptimizationRemark(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization-applied message.
StringRef getPassName() const
const Function & getFunction() const
StringRef getName() const
Return a constant reference to the value's name.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
void emitOptimizationRemarkAnalysis(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization analysis remark message.
DILocation * get() const
Get the underlying DILocation.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Diagnostic information for optimization failures.
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.
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
void emitOptimizationRemarkMissed(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization-missed message.
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
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)
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.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Twine & getMsg() const
const char * getFileName() const
Used in the streaming interface as the general argument type.
static std::string itostr(int64_t X)
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
void emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit a warning when loop vectorization is specified but fails.
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.
void emitLoopInterleaveWarning(LLVMContext &Ctx, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit a warning when loop interleaving is specified but fails.
unsigned getLocCookie() const
Common features for diagnostics dealing with optimization remarks.
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.
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 StringRef getRealLinkageName(StringRef Name)
If special LLVM prefix that is used to inform the asm printer to not emit usual symbol prefix before ...
std::string getMsg() const
const char * getResourceName() const
void emitOptimizationRemarkAnalysisFPCommute(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization analysis remark related to messages about floating-point non-commutativity.
void print(DiagnosticPrinter &DP) const override
FunctionType * getFunctionType() const
Returns the FunctionType for me.
const std::string getLocationStr() const
Return a string with the location information for this diagnostic in the format "file:line:col".
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void print(DiagnosticPrinter &DP) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const Twine & getMsgStr() const
A raw_ostream that writes to an std::string.
LLVM Value Representation.
const Function & getFunction() const
void emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization analysis remark related to messages about pointer aliasing.
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.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
StringRef getFileName() const
LocationClass< Ty > location(Ty &L)