1; RUN: llc < %s -asm-verbose=false -O2 | FileCheck %s 2; RUN: llc < %s -asm-verbose=false -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=YAML %s 3 4; This tests pointer features that may codegen differently in wasm64. 5 6target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" 7target triple = "wasm64-unknown-unknown" 8 9define void @bar(i32 %n) { 10entry: 11 ret void 12} 13 14define void @foo(void (i32)* %fp) { 15entry: 16 call void %fp(i32 1) 17 ret void 18} 19 20define void @test() { 21entry: 22 call void @foo(void (i32)* @bar) 23 store void (i32)* @bar, void (i32)** @fptr 24 ret void 25} 26 27@fptr = global void (i32)* @bar 28 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. 32 33; CHECK: .functype foo (i64) -> () 34; CHECK-NEXT: i32.const 1 35; CHECK-NEXT: local.get 0 36; CHECK-NEXT: i32.wrap_i64 37; CHECK-NEXT: call_indirect (i32) -> () 38 39; CHECK: .functype test () -> () 40; CHECK-NEXT: i64.const bar 41; CHECK-NEXT: call foo 42 43 44; Check we're emitting a 64-bit reloc for `i64.const bar` and the global. 45 46; YAML: Memory: 47; YAML-NEXT: Flags: [ IS_64 ] 48; YAML-NEXT: Initial: 0x1 49 50; YAML: - Type: CODE 51; YAML: - Type: R_WASM_TABLE_INDEX_SLEB64 52; YAML-NEXT: Index: 0 53; YAML-NEXT: Offset: 0x16 54 55; YAML: - Type: DATA 56; YAML: - Type: R_WASM_TABLE_INDEX_I64 57; YAML-NEXT: Index: 0 58; YAML-NEXT: Offset: 0x6 59