16d0c7bc1SPaulo Matos; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
26d0c7bc1SPaulo Matos
3*80fb7823SAlex Bradbury%funcref = type ptr addrspace(20) ;; addrspace 20 is nonintegral
46d0c7bc1SPaulo Matos
56d0c7bc1SPaulo Matos@funcref_table = local_unnamed_addr addrspace(1) global [0 x %funcref] undef
66d0c7bc1SPaulo Matos
76d0c7bc1SPaulo Matos;  CHECK: .tabletype  __funcref_call_table, funcref, 1
86d0c7bc1SPaulo Matos
9c67c9cfeSPaulo Matosdefine void @call_funcref_from_table(i32 %i) {
106d0c7bc1SPaulo Matos; CHECK-LABEL: call_funcref_from_table:
116d0c7bc1SPaulo Matos; CHECK-NEXT: .functype       call_funcref_from_table (i32) -> ()
126d0c7bc1SPaulo Matos; CHECK-NEXT: i32.const       0
136d0c7bc1SPaulo Matos; CHECK-NEXT: local.get       0
146d0c7bc1SPaulo Matos; CHECK-NEXT: table.get       funcref_table
156d0c7bc1SPaulo Matos; CHECK-NEXT: table.set       __funcref_call_table
166d0c7bc1SPaulo Matos; CHECK-NEXT: i32.const       0
176d0c7bc1SPaulo Matos; CHECK-NEXT: call_indirect    __funcref_call_table, () -> ()
186d0c7bc1SPaulo Matos; CHECK-NEXT: i32.const       0
19a96d8285SPaulo Matos; CHECK-NEXT: ref.null_func
206d0c7bc1SPaulo Matos; CHECK-NEXT: table.set       __funcref_call_table
216d0c7bc1SPaulo Matos; CHECK-NEXT: end_function
22*80fb7823SAlex Bradbury  %p = getelementptr [0 x %funcref], ptr addrspace (1) @funcref_table, i32 0, i32 %i
23*80fb7823SAlex Bradbury  %ref = load %funcref, ptr addrspace(1) %p
24*80fb7823SAlex Bradbury  call addrspace(20) void %ref()
25c67c9cfeSPaulo Matos  ret void
26c67c9cfeSPaulo Matos}
276d0c7bc1SPaulo Matos
28b5b5f0acSPaulo Matos;       CHECK: .tabletype funcref_table, funcref
29c67c9cfeSPaulo Matos; CHECK-LABEL: funcref_table:
306d0c7bc1SPaulo Matos
31