[Mlir-commits] [mlir] [MLIR] Enable strict assembly properties for the builtin dialect (PR #225750)

Mehdi Amini llvmlistbot at llvm.org
Wed Sep 23 05:46:07 PDT 2026


https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/225750

Print ModuleOp visibility in the property dictionary and retain its separate discardable attribute dictionary. Update affected assembly tests.

Assisted-by: Codex

>From e1d1c5af24fb729b9788afdee7d1221f0b1c51c8 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Wed, 23 Sep 2026 05:45:11 -0700
Subject: [PATCH] [mlir] Enable strict assembly properties for the builtin
 dialect

Print ModuleOp visibility in the property dictionary and retain its
separate discardable attribute dictionary. Update affected assembly tests.

Assisted-by: Codex
---
 mlir/include/mlir/IR/BuiltinDialect.td    | 1 +
 mlir/include/mlir/IR/BuiltinOps.td        | 2 +-
 mlir/test/IR/module-op.mlir               | 6 ++++++
 mlir/test/Transforms/sccp-callgraph.mlir  | 2 +-
 mlir/test/Transforms/test-symbol-dce.mlir | 4 ++--
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/IR/BuiltinDialect.td b/mlir/include/mlir/IR/BuiltinDialect.td
index c770dd50f3622a..35ea65671a7f88 100644
--- a/mlir/include/mlir/IR/BuiltinDialect.td
+++ b/mlir/include/mlir/IR/BuiltinDialect.td
@@ -20,6 +20,7 @@ def Builtin_Dialect : Dialect {
   let summary =
     "A dialect containing the builtin Attributes, Operations, and Types";
   let name = "builtin";
+  let useStrictPropertiesInAssemblyFormat = 1;
   let cppNamespace = "::mlir";
   let useDefaultAttributePrinterParser = 0;
   let useDefaultTypePrinterParser = 0;
diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td
index f16b686762b48f..fb39d50906493c 100644
--- a/mlir/include/mlir/IR/BuiltinOps.td
+++ b/mlir/include/mlir/IR/BuiltinOps.td
@@ -58,7 +58,7 @@ def ModuleOp : Builtin_Op<"module", [
                        OptionalAttr<StrAttr>:$sym_visibility);
   let regions = (region SizedRegion<1>:$bodyRegion);
 
-  let assemblyFormat = "($sym_name^)? attr-dict-with-keyword $bodyRegion";
+  let assemblyFormat = "($sym_name^)? prop-dict attr-dict-with-keyword $bodyRegion";
   let builders = [OpBuilder<(ins CArg<"std::optional<StringRef>", "{}">:$name)>];
   let extraClassDeclaration = [{
     /// Construct a module from the given location with an optional name.
diff --git a/mlir/test/IR/module-op.mlir b/mlir/test/IR/module-op.mlir
index d99806c92a902b..9401b0887b6b72 100644
--- a/mlir/test/IR/module-op.mlir
+++ b/mlir/test/IR/module-op.mlir
@@ -12,6 +12,12 @@ module attributes {foo.attr = true} {
 
 // -----
 
+// CHECK: module @property_module <sym_visibility = "private"> attributes {foo.attr = true} {
+module @property_module <sym_visibility = "private"> attributes {foo.attr = true} {
+}
+
+// -----
+
 // CHECK: module {
 module {
   // CHECK-NEXT: "foo.result_op"() : () -> i32
diff --git a/mlir/test/Transforms/sccp-callgraph.mlir b/mlir/test/Transforms/sccp-callgraph.mlir
index f31f749b6e75a3..8c74b80625fa79 100644
--- a/mlir/test/Transforms/sccp-callgraph.mlir
+++ b/mlir/test/Transforms/sccp-callgraph.mlir
@@ -51,7 +51,7 @@ func.func @simple_nested() -> i32 {
 /// Check that non-visible nested functions do not track arguments.
 module {
   // NESTED-LABEL: module @nested_module
-  module @nested_module attributes { sym_visibility = "public" } {
+  module @nested_module <sym_visibility = "public"> {
 
     // NESTED: func nested @nested(
     func.func nested @nested(%arg0 : i32) -> (i32, i32) {
diff --git a/mlir/test/Transforms/test-symbol-dce.mlir b/mlir/test/Transforms/test-symbol-dce.mlir
index 90fe93f806d691..a89e59201087f7 100644
--- a/mlir/test/Transforms/test-symbol-dce.mlir
+++ b/mlir/test/Transforms/test-symbol-dce.mlir
@@ -57,14 +57,14 @@ module attributes {test.no_dce_non_hidden_parent} {
     func.func nested @nested_function()
   }
   // NESTED: module @nested_module
-  module @nested_module attributes { sym_visibility = "nested" } {
+  module @nested_module <sym_visibility = "nested"> {
     // NESTED: func nested @nested_function
     func.func nested @nested_function()
   }
 
   // Only private modules can be assumed to be hidden.
   // NESTED: module @private_module
-  module @private_module attributes { sym_visibility = "private" } {
+  module @private_module <sym_visibility = "private"> {
     // NESTED-NOT: func nested @nested_function
     func.func nested @nested_function()
   }



More information about the Mlir-commits mailing list