[all-commits] [llvm/llvm-project] 2ac2e9: [mlir][LLVM] Improve lowering of `llvm.byval` func...
Diego Caballero via All-commits
all-commits at lists.llvm.org
Thu Aug 8 19:28:15 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2ac2e9a5b6c97cbf267db1ef322ed21ebceb2aba
https://github.com/llvm/llvm-project/commit/2ac2e9a5b6c97cbf267db1ef322ed21ebceb2aba
Author: Diego Caballero <dieg0ca6aller0 at gmail.com>
Date: 2024-08-08 (Thu, 08 Aug 2024)
Changed paths:
M mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
M mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
M mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
M mlir/test/Transforms/test-convert-func-op.mlir
M mlir/test/lib/Conversion/FuncToLLVM/TestConvertFuncOp.cpp
Log Message:
-----------
[mlir][LLVM] Improve lowering of `llvm.byval` function arguments (#100028)
When a function argument is annotated with the `llvm.byval` attribute,
[LLVM expects](https://llvm.org/docs/LangRef.html#parameter-attributes)
the function argument type to be an `llvm.ptr`. For example:
```
func.func (%args0 : llvm.ptr {llvm.byval = !llvm.struct<(i32)>} {
...
}
```
Unfortunately, this makes the type conversion context-dependent, which
is something that the type conversion infrastructure (i.e.,
`LLVMTypeConverter` in this particular case) doesn't support. For
example, we may want to convert `MyType` to `llvm.struct<(i32)>` in
general, but to an `llvm.ptr` type only when it's a function argument
passed by value.
To fix this problem, this PR changes the FuncToLLVM conversion logic to
generate an `llvm.ptr` when the function argument has a `llvm.byval`
attribute. An `llvm.load` is inserted into the function to retrieve the
value expected by the argument users.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list