[Mlir-commits] [mlir] [NFC] Change the FuncOp 'UnitAttr's to not be an 'optional'. (PR #180209)

Erich Keane llvmlistbot at llvm.org
Fri Feb 6 07:04:07 PST 2026


https://github.com/erichkeane created https://github.com/llvm/llvm-project/pull/180209

It appears that these all became `Optional` thanks to a series of copy/paste errors going back years.  CallOp doesn't have this 'feature',
  and a "UnitAttr' should be enough as it is effectively already a
  true/false value as it is.

So this patch removes the optional here to simplify the implementation, and changes no tests, as the interface is identical anyway.

>From 103a57cb5037138723b450941e4850fb10a42f66 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Fri, 6 Feb 2026 07:01:07 -0800
Subject: [PATCH] [NFC] Change the FuncOp 'UnitAttr's to not be an 'optional'.

It appears that these all became `Optional` thanks to a series of
copy/paste errors going back years.  CallOp doesn't have this 'feature',
  and a "UnitAttr' should be enough as it is effectively already a
  true/false value as it is.

So this patch removes the optional here to simplify the implementation,
and changes no tests, as the interface is identical anyway.
---
 mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 34 ++++++---------------
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index c57d0a15c404a..41240d94e3fcc 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -1958,7 +1958,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
     UnitAttr:$dso_local,
     DefaultValuedAttr<CConv, "CConv::C">:$CConv,
     OptionalAttr<SymbolRefAttr>:$comdat,
-    OptionalAttr<UnitAttr>:$convergent,
+    UnitAttr:$convergent,
     OptionalAttr<FlatSymbolRefAttr>:$personality,
     OptionalAttr<StrAttr>:$garbageCollector,
     OptionalAttr<ArrayAttr>:$passthrough,
@@ -1967,15 +1967,10 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
     OptionalAttr<I64Attr>:$function_entry_count,
     OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
     DefaultValuedAttr<Visibility, "mlir::LLVM::Visibility::Default">:$visibility_,
-    OptionalAttr<UnitAttr>:$arm_streaming,
-    OptionalAttr<UnitAttr>:$arm_locally_streaming,
-    OptionalAttr<UnitAttr>:$arm_streaming_compatible,
-    OptionalAttr<UnitAttr>:$arm_new_za,
-    OptionalAttr<UnitAttr>:$arm_in_za,
-    OptionalAttr<UnitAttr>:$arm_out_za,
-    OptionalAttr<UnitAttr>:$arm_inout_za,
-    OptionalAttr<UnitAttr>:$arm_preserves_za,
-    OptionalAttr<StrAttr>:$section,
+    UnitAttr:$arm_streaming, UnitAttr:$arm_locally_streaming,
+    UnitAttr:$arm_streaming_compatible, UnitAttr:$arm_new_za,
+    UnitAttr:$arm_in_za, UnitAttr:$arm_out_za, UnitAttr:$arm_inout_za,
+    UnitAttr:$arm_preserves_za, OptionalAttr<StrAttr>:$section,
     OptionalAttr<UnnamedAddr>:$unnamed_addr,
     OptionalAttr<I64Attr>:$alignment,
     OptionalAttr<LLVM_VScaleRangeAttr>:$vscale_range,
@@ -1992,20 +1987,11 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
     OptionalAttr<StrAttr>:$fp_contract,
     OptionalAttr<StrAttr>:$instrument_function_entry,
     OptionalAttr<StrAttr>:$instrument_function_exit,
-    OptionalAttr<UnitAttr>:$no_inline,
-    OptionalAttr<UnitAttr>:$always_inline,
-    OptionalAttr<UnitAttr>:$inline_hint,
-    OptionalAttr<UnitAttr>:$no_unwind,
-    OptionalAttr<UnitAttr>:$will_return,
-    OptionalAttr<UnitAttr>:$noreturn,
-    OptionalAttr<UnitAttr>:$optimize_none,
-    OptionalAttr<UnitAttr>:$returns_twice,
-    OptionalAttr<UnitAttr>:$hot,
-    OptionalAttr<UnitAttr>:$cold,
-    OptionalAttr<UnitAttr>:$noduplicate,
-    OptionalAttr<UnitAttr>:$no_caller_saved_registers,
-    OptionalAttr<UnitAttr>:$nocallback,
-    OptionalAttr<StrAttr>:$modular_format,
+    UnitAttr:$no_inline, UnitAttr:$always_inline, UnitAttr:$inline_hint,
+    UnitAttr:$no_unwind, UnitAttr:$will_return, UnitAttr:$noreturn,
+    UnitAttr:$optimize_none, UnitAttr:$returns_twice, UnitAttr:$hot,
+    UnitAttr:$cold, UnitAttr:$noduplicate, UnitAttr:$no_caller_saved_registers,
+    UnitAttr:$nocallback, OptionalAttr<StrAttr>:$modular_format,
     OptionalAttr<ArrayAttr>:$nobuiltins,
     OptionalAttr<DenseI32ArrayAttr>:$allocsize,
     OptionalAttr<LLVM_VecTypeHintAttr>:$vec_type_hint,



More information about the Mlir-commits mailing list