[Mlir-commits] [mlir] [mlir][LLVMIR] Add IFuncOp to LLVM dialect (PR #147697)
Tobias Gysi
llvmlistbot at llvm.org
Fri Jul 11 12:13:03 PDT 2025
================
@@ -0,0 +1,80 @@
+; RUN: mlir-translate --import-llvm %s --split-input-file | FileCheck %s
+
+; CHECK: llvm.mlir.ifunc external @foo : !llvm.func<void (ptr, i32)>, !llvm.ptr @resolve_foo {dso_local}
+ at foo = dso_local ifunc void (ptr, i32), ptr @resolve_foo
+
+define dso_local void @call_foo(ptr noundef %0, i32 noundef %1) {
+ %3 = alloca ptr, align 8
+ %4 = alloca i32, align 4
+ store ptr %0, ptr %3, align 8
+ store i32 %1, ptr %4, align 4
+ %5 = load ptr, ptr %3, align 8
+ %6 = load i32, ptr %4, align 4
+; CHECK: llvm.call @foo
+ call void @foo(ptr noundef %5, i32 noundef %6)
+ ret void
+}
+
+define dso_local void @call_indirect_foo(ptr noundef %0, i32 noundef %1) {
+ %3 = alloca ptr, align 8
+ %4 = alloca i32, align 4
+ %5 = alloca ptr, align 8
+; CHECK: [[CALLEE:%[0-9]+]] = llvm.mlir.addressof @foo
+; CHECK: llvm.store [[CALLEE]], [[STORED:%[0-9]+]]
+; CHECK: [[LOADED_CALLEE:%[0-9]+]] = llvm.load [[STORED]]
+ store ptr %0, ptr %3, align 8
+ store i32 %1, ptr %4, align 4
+ store ptr @foo, ptr %5, align 8
+ %6 = load ptr, ptr %5, align 8
+ %7 = load ptr, ptr %3, align 8
+ %8 = load i32, ptr %4, align 4
+ call void %6(ptr noundef %7, i32 noundef %8)
----------------
gysit wrote:
Can we pass all three arguments as function arguments as well to shorten the test?
https://github.com/llvm/llvm-project/pull/147697
More information about the Mlir-commits
mailing list