Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][EmitC] Fix call ops with zero arguments in func to emitc conversion #94936

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

simon-camp
Copy link
Contributor

No description provided.

@simon-camp simon-camp marked this pull request as ready for review June 10, 2024 07:49
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 10, 2024

@llvm/pr-subscribers-mlir-emitc

@llvm/pr-subscribers-mlir

Author: Simon Camphausen (simon-camp)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/94936.diff

2 Files Affected:

  • (modified) mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp (+1-1)
  • (modified) mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir (+16)
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
+}

@simon-camp simon-camp changed the title [mlir][EmitC] Fix call ops with zero arguments [mlir][EmitC] Fix call ops with zero arguments in func to emitc conversion Jun 10, 2024
Copy link
Contributor

@mgehre-amd mgehre-amd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@simon-camp simon-camp merged commit 346bd91 into llvm:main Jun 10, 2024
7 checks passed
@simon-camp simon-camp deleted the emitc.call.void branch June 10, 2024 11:40
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
mgehre-amd pushed a commit to Xilinx/llvm-project that referenced this pull request Jul 10, 2024
mgehre-amd added a commit to Xilinx/llvm-project that referenced this pull request Jul 10, 2024
[mlir][EmitC] Fix call ops with zero arguments in func to emitc conversion (llvm#94936)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants