xref: /llvm-project/llvm/test/CodeGen/WebAssembly/call-indirect.ll (revision c3536b263f253a69fb336fb0617ee33a01a5c5dd)
1; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 | FileCheck --check-prefixes=CHECK,NOREF %s
2; RUN: llc < %s -asm-verbose=false -mattr=+call-indirect-overlong -O2 | FileCheck --check-prefixes=CHECK,REF %s
3; RUN: llc < %s -asm-verbose=false -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=OBJ %s
4
5; Test that compilation units with call_indirect but without any
6; function pointer declarations still get a table.
7
8target triple = "wasm32-unknown-unknown"
9
10; CHECK-LABEL: call_indirect_void:
11; CHECK-NEXT: .functype call_indirect_void (i32) -> ()
12; CHECK-NEXT: local.get 0
13; REF:        call_indirect __indirect_function_table, () -> ()
14; NOREF:      call_indirect () -> ()
15; CHECK-NEXT: end_function
16define void @call_indirect_void(ptr %callee) {
17  call void %callee()
18  ret void
19}
20
21; OBJ:    Imports:
22; OBJ-NEXT:      - Module:          env
23; OBJ-NEXT:        Field:           __linear_memory
24; OBJ-NEXT:        Kind:            MEMORY
25; OBJ-NEXT:        Memory:
26; OBJ-NEXT:          Minimum:         0x0
27; OBJ-NEXT:      - Module:          env
28; OBJ-NEXT:        Field:           __indirect_function_table
29; OBJ-NEXT:        Kind:            TABLE
30