Files
clang-p2996/llvm/test/CodeGen/WebAssembly/funcref-call.ll
Paulo Matos 0c7495848a [WebAssembly] Fix call_indirect on funcrefs
The currently implementation of funcrefs is broken since it is putting
the funcref itself on the stack before the call_indirect. Instead what
should be on the stack is the constant 0, which is the index at which
we store the funcref in __funcref_call_table.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D111152
2021-10-06 10:11:53 +02:00

25 lines
739 B
LLVM

; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
%func = type void ()
%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
define void @call_funcref(%funcref %ref) {
call addrspace(20) void %ref()
ret void
}
; CHECK: .tabletype __funcref_call_table, funcref, 1
; CHECK-LABEL: call_funcref:
; CHECK-NEXT: functype call_funcref (funcref) -> ()
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: local.get 0
; CHECK-NEXT: table.set __funcref_call_table
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: ref.null func
; CHECK-NEXT: table.set __funcref_call_table
; CHECK-NEXT: end_function