diff --git a/mlir/include/mlir/Interfaces/FunctionInterfaces.td b/mlir/include/mlir/Interfaces/FunctionInterfaces.td index 4c8d5b02ed92a..f701e828ed641 100644 --- a/mlir/include/mlir/Interfaces/FunctionInterfaces.td +++ b/mlir/include/mlir/Interfaces/FunctionInterfaces.td @@ -490,8 +490,11 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [ } /// Return an ArrayAttr containing all result attribute dictionaries of this - /// function, or nullptr if no result have attributes. - ::mlir::ArrayAttr getAllResultAttrs() { return $_op.getResAttrsAttr(); } + /// function, or nullptr if no results have attributes. + ::mlir::ArrayAttr getAllResultAttrs() { + auto attrs = $_op.getResAttrsAttr(); + return attrs && !attrs.empty() ? attrs : nullptr; + } /// Return all result attributes of this function. void getAllResultAttrs(::llvm::SmallVectorImpl<::mlir::DictionaryAttr> &result) { diff --git a/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir b/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir index bd281620c2918..4cb31f8f92661 100644 --- a/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir +++ b/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir @@ -96,3 +96,10 @@ func.func private @badllvmlinkage(i32) attributes { "llvm.linkage" = 3 : i64 } / func.func @variadic_func(%arg0: i32) attributes { "func.varargs" = true, "llvm.emit_c_interface" } { return } + +// ----- + +// CHECK-LABEL: llvm.func @empty_res_attrs() +func.func @empty_res_attrs() attributes {res_attrs = []} { + return +}