[Mlir-commits] [mlir] [MLIR] fix func.func to llvm.func lowering where no_inline attribute is not propagated over (PR #142088)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 29 22:48:27 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Keyi Zhang (Kuree)

<details>
<summary>Changes</summary>

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.

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


2 Files Affected:

- (modified) mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp (+3) 
- (modified) mlir/test/Conversion/FuncToLLVM/func-to-llvm.mlir (+5) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/142088


More information about the Mlir-commits mailing list