1 ; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 | FileCheck %s
2 ; RUN: llc < %s -asm-verbose=false -mattr=+reference-types -O2 | FileCheck --check-prefix=REF %s
3 ; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=YAML %s
5 ; This tests pointer features that may codegen differently in wasm64.
7 target triple = "wasm64-unknown-unknown"
9 define void @bar(i32 %n) {
14 define void @foo(ptr %fp) {
22 call void @foo(ptr @bar)
23 store ptr @bar, ptr @fptr
27 @fptr = global ptr @bar
29 ; For simplicity (and compatibility with UB C/C++ code) we keep all types
30 ; of pointers the same size, so function pointers (which are 32-bit indices
31 ; in Wasm) are represented as 64-bit until called.
34 ; CHECK: .functype foo (i64) -> ()
35 ; CHECK-NEXT: i32.const 1
36 ; CHECK-NEXT: local.get 0
37 ; CHECK-NEXT: call_indirect (i32) -> ()
38 ; REF: call_indirect __indirect_function_table, (i32) -> ()
40 ; CHECK: .functype test () -> ()
41 ; CHECK-NEXT: i64.const bar
42 ; CHECK-NEXT: call foo
45 ; Check we're emitting a 64-bit relocs for the call_indirect, the
46 ; `i64.const bar` reference in code, and the global.
49 ; YAML-NEXT: Flags: [ IS_64 ]
50 ; YAML-NEXT: Minimum: 0x1
53 ; YAML: - Type: R_WASM_TABLE_INDEX_SLEB64
55 ; YAML-NEXT: Offset: 0x15
56 ; YAML: - Type: R_WASM_TABLE_INDEX_SLEB64
58 ; YAML-NEXT: Offset: 0x28
61 ; YAML: - Type: R_WASM_TABLE_INDEX_I64
63 ; YAML-NEXT: Offset: 0x6