xref: /llvm-project/llvm/test/CodeGen/WebAssembly/funcref-table_call.ll (revision 1bd1a4407058c4a159eee6f6956f3bcabeb0d7f8)
1; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
2
3%funcref = type ptr addrspace(20) ;; addrspace 20 is nonintegral
4
5@funcref_table = local_unnamed_addr addrspace(1) global [0 x %funcref] undef
6
7;  CHECK: .tabletype  __funcref_call_table, funcref, 1
8
9declare %funcref @llvm.wasm.table.get.funcref(ptr addrspace(1), i32) nounwind
10
11define void @call_funcref_from_table(i32 %i) {
12; CHECK-LABEL: call_funcref_from_table:
13; CHECK-NEXT: .functype       call_funcref_from_table (i32) -> ()
14; CHECK-NEXT: i32.const       0
15; CHECK-NEXT: local.get       0
16; CHECK-NEXT: table.get       funcref_table
17; CHECK-NEXT: table.set       __funcref_call_table
18; CHECK-NEXT: i32.const       0
19; CHECK-NEXT: call_indirect    __funcref_call_table, () -> ()
20; CHECK-NEXT: i32.const       0
21; CHECK-NEXT: ref.null_func
22; CHECK-NEXT: table.set       __funcref_call_table
23; CHECK-NEXT: end_function
24  %ref = call %funcref @llvm.wasm.table.get.funcref(ptr addrspace(1) @funcref_table, i32 %i)
25  call addrspace(20) void %ref()
26  ret void
27}
28
29;       CHECK: .tabletype funcref_table, funcref
30; CHECK-LABEL: funcref_table:
31
32