[Mlir-commits] [mlir] [mlir] Add metadata to Diagnostic. (PR #99398)
weiwei chen
llvmlistbot at llvm.org
Fri Jul 19 20:42:09 PDT 2024
https://github.com/weiweichen updated https://github.com/llvm/llvm-project/pull/99398
>From 662546872cd5f539bd932838c5f1edcda08d4091 Mon Sep 17 00:00:00 2001
From: Weiwei Chen <weiwei.chen at modular.com>
Date: Wed, 17 Jul 2024 18:00:05 -0400
Subject: [PATCH 1/3] Add metadat to Diagnostic.
---
mlir/include/mlir/IR/Diagnostics.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h
index bb2e1bb183e9b..1ef902ae5439c 100644
--- a/mlir/include/mlir/IR/Diagnostics.h
+++ b/mlir/include/mlir/IR/Diagnostics.h
@@ -271,6 +271,9 @@ class Diagnostic {
return failure();
}
+ /// Returns the current list of diagnostic metadata.
+ SmallVector<DiagnosticArgument, 1>& getMetaData() { return metadata; }
+
private:
Diagnostic(const Diagnostic &rhs) = delete;
Diagnostic &operator=(const Diagnostic &rhs) = delete;
@@ -290,6 +293,9 @@ class Diagnostic {
/// A list of attached notes.
NoteVector notes;
+
+ /// A list of metadata attached to this Diagnostic.
+ SmallVector<DiagnosticArgument, 1> metadata;
};
inline raw_ostream &operator<<(raw_ostream &os, const Diagnostic &diag) {
>From 90d8968d99cf6a854cae4c55fa57160a99291f7a Mon Sep 17 00:00:00 2001
From: Weiwei Chen <weiwei.chen at modular.com>
Date: Fri, 19 Jul 2024 19:43:25 -0400
Subject: [PATCH 2/3] Apply review comment and format.
---
mlir/include/mlir/IR/Diagnostics.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h
index 1ef902ae5439c..f87e5b2170e68 100644
--- a/mlir/include/mlir/IR/Diagnostics.h
+++ b/mlir/include/mlir/IR/Diagnostics.h
@@ -272,7 +272,7 @@ class Diagnostic {
}
/// Returns the current list of diagnostic metadata.
- SmallVector<DiagnosticArgument, 1>& getMetaData() { return metadata; }
+ SmallVector<DiagnosticArgument, 0> &getMetaData() { return metadata; }
private:
Diagnostic(const Diagnostic &rhs) = delete;
@@ -295,7 +295,7 @@ class Diagnostic {
NoteVector notes;
/// A list of metadata attached to this Diagnostic.
- SmallVector<DiagnosticArgument, 1> metadata;
+ SmallVector<DiagnosticArgument, 0> metadata;
};
inline raw_ostream &operator<<(raw_ostream &os, const Diagnostic &diag) {
>From 0b33c7b50d26aa6e3d3827e4502e394e20f07355 Mon Sep 17 00:00:00 2001
From: Weiwei Chen <weiwei.chen at modular.com>
Date: Fri, 19 Jul 2024 23:41:32 -0400
Subject: [PATCH 3/3] Add test for Diagnostic metadata.
---
mlir/include/mlir/IR/Diagnostics.h | 2 +-
mlir/test/lib/IR/CMakeLists.txt | 1 +
mlir/tools/mlir-opt/mlir-opt.cpp | 2 ++
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h
index f87e5b2170e68..cb30bb3f59688 100644
--- a/mlir/include/mlir/IR/Diagnostics.h
+++ b/mlir/include/mlir/IR/Diagnostics.h
@@ -272,7 +272,7 @@ class Diagnostic {
}
/// Returns the current list of diagnostic metadata.
- SmallVector<DiagnosticArgument, 0> &getMetaData() { return metadata; }
+ SmallVectorImpl<DiagnosticArgument> &getMetadata() { return metadata; }
private:
Diagnostic(const Diagnostic &rhs) = delete;
diff --git a/mlir/test/lib/IR/CMakeLists.txt b/mlir/test/lib/IR/CMakeLists.txt
index faaa3bb8db24c..01297ad0a1148 100644
--- a/mlir/test/lib/IR/CMakeLists.txt
+++ b/mlir/test/lib/IR/CMakeLists.txt
@@ -6,6 +6,7 @@ add_mlir_library(MLIRTestIR
TestBuiltinDistinctAttributes.cpp
TestClone.cpp
TestDiagnostics.cpp
+ TestDiagnosticsMetadata.cpp
TestDominance.cpp
TestFunc.cpp
TestInterfaces.cpp
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index 149f9d59961b8..1695ad887470b 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -92,6 +92,7 @@ void registerTestDataLayoutQuery();
void registerTestDeadCodeAnalysisPass();
void registerTestDecomposeCallGraphTypes();
void registerTestDiagnosticsPass();
+void registerTestDiagnosticsMetadataPass();
void registerTestDominancePass();
void registerTestDynamicPipelinePass();
void registerTestEmulateNarrowTypePass();
@@ -225,6 +226,7 @@ void registerTestPasses() {
mlir::test::registerTestDeadCodeAnalysisPass();
mlir::test::registerTestDecomposeCallGraphTypes();
mlir::test::registerTestDiagnosticsPass();
+ mlir::test::registerTestDiagnosticsMetadataPass();
mlir::test::registerTestDominancePass();
mlir::test::registerTestDynamicPipelinePass();
mlir::test::registerTestEmulateNarrowTypePass();
More information about the Mlir-commits
mailing list