[Mlir-commits] [mlir] [mlir] Decouple DenseResourceElementsAttr from BuiltinDialect (PR #191486)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Apr 10 12:20:44 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- mlir/include/mlir/IR/BuiltinAttributes.h mlir/include/mlir/IR/DialectResourceBlobManager.h mlir/lib/AsmParser/AttributeParser.cpp mlir/lib/IR/AsmPrinter.cpp mlir/lib/IR/BuiltinAttributes.cpp mlir/lib/IR/BuiltinDialect.cpp mlir/unittests/IR/BlobManagerTest.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/include/mlir/IR/DialectResourceBlobManager.h b/mlir/include/mlir/IR/DialectResourceBlobManager.h
index ec2cc0798..b2e9bf45e 100644
--- a/mlir/include/mlir/IR/DialectResourceBlobManager.h
+++ b/mlir/include/mlir/IR/DialectResourceBlobManager.h
@@ -233,12 +233,12 @@ public:
/// Direct construction with an explicit dialect owner. Uses its own TypeID.
DenseResourceBlobHandle(BlobEntry *entry, Dialect *dialect)
- : AsmDialectResourceHandle(entry,
- TypeID::get<DenseResourceBlobHandle>(),
+ : AsmDialectResourceHandle(entry, TypeID::get<DenseResourceBlobHandle>(),
dialect) {}
/// Implicit conversion from any dialect-specific blob handle. Preserves the
- /// original handle's TypeID so that dyn_cast to the original type still works.
+ /// original handle's TypeID so that dyn_cast to the original type still
+ /// works.
template <typename DialectT>
DenseResourceBlobHandle(DialectResourceBlobHandle<DialectT> handle)
: AsmDialectResourceHandle(handle) {}
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index 19b683120..85a68e9b3 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -1142,8 +1142,8 @@ Attribute Parser::parseDenseResourceElementsAttr(Type attrType) {
interface->declareResource(blobKey);
if (failed(result))
return emitError(loc, "unknown 'resource' key '" + Twine(blobKey) +
- "' for dialect '" +
- dialect->getNamespace() + "'"),
+ "' for dialect '" + dialect->getNamespace() +
+ "'"),
nullptr;
entry.first = interface->getResourceKey(*result);
entry.second = *result;
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 2ca9f2a7c..8a6cbaecc 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -2580,7 +2580,8 @@ void AsmPrinter::Impl::printAttributeImpl(Attribute attr,
llvm::printEscapedString(
(dialect->getNamespace() + "::" + handle.getKey()).str(), os);
os << '"';
- // Register the resource with the correct dialect for the resource section.
+ // Register the resource with the correct dialect for the resource
+ // section.
state.getDialectResources()[dialect].insert(handle);
} else {
printResourceHandle(handle);
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index e4a4cd107..0811493a2 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -1417,7 +1417,8 @@ DenseResourceElementsAttr DenseResourceElementsAttr::get(ShapedType type,
assert(dialect && "dialect must not be null");
auto *iface =
dialect->getRegisteredInterface<ResourceBlobManagerDialectInterface>();
- assert(iface && "dialect does not provide ResourceBlobManagerDialectInterface");
+ assert(iface &&
+ "dialect does not provide ResourceBlobManagerDialectInterface");
auto &blobMgr = iface->getBlobManager();
auto &entry = blobMgr.insert(blobName, std::move(blob));
return get(type, DenseResourceBlobHandle(&entry, dialect));
diff --git a/mlir/unittests/IR/BlobManagerTest.cpp b/mlir/unittests/IR/BlobManagerTest.cpp
index 05c4c6116..78c6d868a 100644
--- a/mlir/unittests/IR/BlobManagerTest.cpp
+++ b/mlir/unittests/IR/BlobManagerTest.cpp
@@ -88,8 +88,8 @@ TEST(DialectResourceBlobManagerTest, CustomDialectResource) {
data.size() * sizeof(int32_t)),
alignof(int32_t));
- auto attr = DenseResourceElementsAttr::get(type, "test_blob",
- std::move(blob), testDialect);
+ auto attr = DenseResourceElementsAttr::get(type, "test_blob", std::move(blob),
+ testDialect);
ASSERT_TRUE(attr);
// The resource handle should point to the test dialect, not BuiltinDialect.
``````````
</details>
https://github.com/llvm/llvm-project/pull/191486
More information about the Mlir-commits
mailing list