[Mlir-commits] [mlir] [mlir][LLVMIR] Add IFuncOp to LLVM dialect (PR #147697)
Tobias Gysi
llvmlistbot at llvm.org
Fri Jul 11 12:13:01 PDT 2025
================
@@ -0,0 +1,93 @@
+// RUN: mlir-translate -mlir-to-llvmir %s --split-input-file | FileCheck %s
+
+// CHECK: @foo = dso_local ifunc void (ptr, i32), ptr @resolve_foo
+llvm.mlir.ifunc external @foo : !llvm.func<void (ptr, i32)>, !llvm.ptr @resolve_foo {dso_local}
+llvm.func @call_foo(%arg0: !llvm.ptr {llvm.noundef}, %arg1: i32 {llvm.noundef}) attributes {dso_local} {
+ %0 = llvm.mlir.constant(1 : i32) : i32
+ %1 = llvm.alloca %0 x !llvm.ptr {alignment = 8 : i64} : (i32) -> !llvm.ptr
+ %2 = llvm.alloca %0 x i32 {alignment = 4 : i64} : (i32) -> !llvm.ptr
+ llvm.store %arg0, %1 {alignment = 8 : i64} : !llvm.ptr, !llvm.ptr
+ llvm.store %arg1, %2 {alignment = 4 : i64} : i32, !llvm.ptr
+ %3 = llvm.load %1 {alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr
+ %4 = llvm.load %2 {alignment = 4 : i64} : !llvm.ptr -> i32
+// CHECK: call void @foo
+ llvm.call @foo(%3, %4) : (!llvm.ptr {llvm.noundef}, i32 {llvm.noundef}) -> ()
----------------
gysit wrote:
```suggestion
// CHECK: call void @foo
llvm.call @foo(%arg0, %arg1) : (!llvm.ptr {llvm.noundef}, i32 {llvm.noundef}) -> ()
```
nit: I think that can be shortened further?
https://github.com/llvm/llvm-project/pull/147697
More information about the Mlir-commits
mailing list