[Mlir-commits] [mlir] [MLIR] fix func.func to llvm.func lowering where no_inline attribute is not propagated over (PR #142088)
Keyi Zhang
llvmlistbot at llvm.org
Thu May 29 22:47:51 PDT 2025
https://github.com/Kuree created https://github.com/llvm/llvm-project/pull/142088
See https://godbolt.org/z/43c84TEGh
`func.func` `no_inline` attribute is not propagated to `llvm.func` even though both of them supports no inline attribute.
I had to put the fix in inside the rewrite function instead of `mlir::convertFuncOpToLLVMFuncOp` because it takes `FunctionOpInterface`, which does not have a named method to get no inline information without using get attributes. I'm happy to switch to the latter method.
>From 7456f1b2e4aade7f1e74f844c690bfca08ad5f9a Mon Sep 17 00:00:00 2001
From: Keyi Zhang <keyi at cs.stanford.edu>
Date: Thu, 29 May 2025 22:40:55 -0700
Subject: [PATCH] [MLIR] fix func.func to llvm.func lowering where no_inline
attribute is not propagated over
---
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp | 3 +++
mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
index 328c605add65c..bf8e231fde2f4 100644
--- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
+++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
@@ -490,6 +490,9 @@ struct FuncOpConversion : public ConvertOpToLLVMPattern<func::FuncOp> {
if (failed(newFuncOp))
return rewriter.notifyMatchFailure(funcOp, "Could not convert funcop");
+ // Propagate noinline attribute
+ newFuncOp->setNoInline(funcOp.getNoInline());
+
rewriter.eraseOp(funcOp);
return success();
}
diff --git a/mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir b/mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir
index 2113557fbbb15..4a664ec7aa0fa 100644
--- a/mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir
+++ b/mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir
@@ -563,6 +563,11 @@ func.func @non_convertible_arg_type(%arg: vector<1xtf32>) {
return
}
+// CHECK: llvm.func @no_inline() attributes {no_inline}
+func.func @no_inline() attributes {no_inline} {
+ return
+}
+
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%toplevel_module: !transform.any_op {transform.readonly}) {
%func = transform.structured.match ops{["func.func"]} in %toplevel_module
More information about the Mlir-commits
mailing list