[Mlir-commits] [mlir] [mlir][EmitC] Fix call ops with zero arguments (PR #94936)
Simon Camphausen
llvmlistbot at llvm.org
Mon Jun 10 00:49:49 PDT 2024
https://github.com/simon-camp created https://github.com/llvm/llvm-project/pull/94936
None
>From 05054440ffb6c21e71901660469af56ba312fff4 Mon Sep 17 00:00:00 2001
From: Simon Camphausen <simon.camphausen at iml.fraunhofer.de>
Date: Mon, 10 Jun 2024 07:48:44 +0000
Subject: [PATCH] [mlir][EmitC] Fix call ops with zero arguments
---
mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp | 2 +-
.../Conversion/FuncToEmitC/func-to-emitc.mlir | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp b/mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp
index 6a8ecb7b00473..f0bb2093af277 100644
--- a/mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp
+++ b/mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp
@@ -38,7 +38,7 @@ class CallOpConversion final : public OpConversionPattern<func::CallOp> {
rewriter.replaceOpWithNewOp<emitc::CallOp>(
callOp,
- callOp.getNumResults() ? callOp.getResult(0).getType() : nullptr,
+ callOp.getNumResults() ? callOp.getResult(0).getType() : TypeRange{},
adaptor.getOperands(), callOp->getAttrs());
return success();
diff --git a/mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir b/mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir
index 5c96cf1ce0d34..5730f7a4814fa 100644
--- a/mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir
+++ b/mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir
@@ -58,3 +58,19 @@ func.func @call(%arg0: i32) -> i32 {
// CHECK-LABEL: emitc.func private @return_i32(i32) -> i32 attributes {specifiers = ["extern"]}
func.func private @return_i32(%arg0: i32) -> i32
+
+// -----
+
+// CHECK-LABEL: emitc.func private @return_void() attributes {specifiers = ["static"]}
+// CHECK-NEXT: emitc.return
+func.func private @return_void() {
+ return
+}
+
+// CHECK-LABEL: emitc.func @call()
+// CHECK-NEXT: emitc.call @return_void() : () -> ()
+// CHECK-NEXT: emitc.return
+func.func @call() {
+ call @return_void() : () -> ()
+ return
+}
More information about the Mlir-commits
mailing list