[llvm] 49e3860 - [Sanitizer] Create DiagnosticInfoInstrumentation for IR Instrumentation reporting. (#106356)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 7 21:40:20 PDT 2024
Author: Chaitanya
Date: 2024-09-08T10:10:16+05:30
New Revision: 49e38606cdad9eb2414a41d2b81903f0b516984d
URL: https://github.com/llvm/llvm-project/commit/49e38606cdad9eb2414a41d2b81903f0b516984d
DIFF: https://github.com/llvm/llvm-project/commit/49e38606cdad9eb2414a41d2b81903f0b516984d.diff
LOG: [Sanitizer] Create DiagnosticInfoInstrumentation for IR Instrumentation reporting. (#106356)
This PR adds DK_Instrumentation enum to DiagnosticKind and
DiagnosticInfoInstrumentation is extended from DiagnosticsInfo for IR
instrumentation reporting.
Added:
Modified:
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/IR/DiagnosticInfo.cpp
llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h
index b35923efdad5d2..0abff016b77792 100644
--- a/llvm/include/llvm/IR/DiagnosticInfo.h
+++ b/llvm/include/llvm/IR/DiagnosticInfo.h
@@ -65,6 +65,7 @@ enum DiagnosticKind {
DK_Lowering,
DK_DebugMetadataVersion,
DK_DebugMetadataInvalid,
+ DK_Instrumentation,
DK_ISelFallback,
DK_SampleProfile,
DK_OptimizationRemark,
@@ -950,6 +951,22 @@ class DiagnosticInfoMIRParser : public DiagnosticInfo {
}
};
+/// Diagnostic information for IR instrumentation reporting.
+class DiagnosticInfoInstrumentation : public DiagnosticInfo {
+ const Twine &Msg;
+
+public:
+ DiagnosticInfoInstrumentation(const Twine &DiagMsg,
+ DiagnosticSeverity Severity = DS_Warning)
+ : DiagnosticInfo(DK_Instrumentation, Severity), Msg(DiagMsg) {}
+
+ void print(DiagnosticPrinter &DP) const override;
+
+ static bool classof(const DiagnosticInfo *DI) {
+ return DI->getKind() == DK_Instrumentation;
+ }
+};
+
/// Diagnostic information for ISel fallback path.
class DiagnosticInfoISelFallback : public DiagnosticInfo {
/// The function that is concerned by this diagnostic.
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp
index 623f372bb9e740..234280754d547f 100644
--- a/llvm/lib/IR/DiagnosticInfo.cpp
+++ b/llvm/lib/IR/DiagnosticInfo.cpp
@@ -375,6 +375,10 @@ void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const {
DP << Str;
}
+void DiagnosticInfoInstrumentation::print(DiagnosticPrinter &DP) const {
+ DP << Msg;
+}
+
void DiagnosticInfoISelFallback::print(DiagnosticPrinter &DP) const {
DP << "Instruction selection used fallback path for " << getFunction();
}
diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
index 305bae0e2010d1..9c436da7f00612 100644
--- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -24,19 +24,6 @@ static cl::opt<bool> ClIgnoreRedundantInstrumentation(
"ignore-redundant-instrumentation",
cl::desc("Ignore redundant instrumentation"), cl::Hidden, cl::init(false));
-namespace {
-/// Diagnostic information for IR instrumentation reporting.
-class DiagnosticInfoInstrumentation : public DiagnosticInfo {
- const Twine &Msg;
-
-public:
- DiagnosticInfoInstrumentation(const Twine &DiagMsg,
- DiagnosticSeverity Severity = DS_Warning)
- : DiagnosticInfo(DK_Linker, Severity), Msg(DiagMsg) {}
- void print(DiagnosticPrinter &DP) const override { DP << Msg; }
-};
-} // namespace
-
/// Check if module has flag attached, if not add the flag.
bool llvm::checkIfAlreadyInstrumented(Module &M, StringRef Flag) {
if (!M.getModuleFlag(Flag)) {
More information about the llvm-commits
mailing list