brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 2accd41 Raw
64 lines · plain
1; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 | FileCheck %s2; RUN: llc < %s -asm-verbose=false -mattr=+reference-types -O2 | FileCheck --check-prefix=REF %s3; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=YAML %s4 5; This tests pointer features that may codegen differently in wasm64.6 7target triple = "wasm64-unknown-unknown"8 9define void @bar(i32 %n) {10entry:11  ret void12}13 14define void @foo(ptr %fp) {15entry:16  call void %fp(i32 1)17  ret void18}19 20define void @test() {21entry:22  call void @foo(ptr @bar)23  store ptr @bar, ptr @fptr24  ret void25}26 27@fptr = global ptr @bar28 29; For simplicity (and compatibility with UB C/C++ code) we keep all types30; of pointers the same size, so function pointers (which are 32-bit indices31; in Wasm) are represented as 64-bit until called.32 33; CHECK-LABEL: foo:34; CHECK:      .functype foo (i64) -> ()35; CHECK-NEXT: i32.const 136; CHECK-NEXT: local.get 037; CHECK-NEXT: call_indirect (i32) -> ()38; REF:        call_indirect __indirect_function_table, (i32) -> ()39 40; CHECK:      .functype test () -> ()41; CHECK-NEXT: i64.const bar42; CHECK-NEXT: call foo43 44 45; Check we're emitting a 64-bit relocs for the call_indirect, the46; `i64.const bar` reference in code, and the global.47 48; YAML:      Memory:49; YAML-NEXT:   Flags:   [ IS_64 ]50; YAML-NEXT:   Minimum: 0x151 52; YAML:      - Type:   CODE53; YAML:      - Type:   R_WASM_TABLE_INDEX_SLEB6454; YAML-NEXT:   Index:  055; YAML-NEXT:   Offset: 0x1556; YAML:      - Type:   R_WASM_TABLE_INDEX_SLEB6457; YAML-NEXT:   Index:  058; YAML-NEXT:   Offset: 0x2859 60; YAML:      - Type:   DATA61; YAML:      - Type:   R_WASM_TABLE_INDEX_I6462; YAML-NEXT:   Index:  063; YAML-NEXT:   Offset: 0x664