76 lines · plain
1# RUN: llvm-mc -mattr=+reference-types -triple=wasm32-unknown-unknown -filetype=obj -o %t.o %s2# RUN: wasm-ld --allow-undefined -o %t1.wasm %t.o3# RUN: obj2yaml %t1.wasm | FileCheck %s4 5.tabletype t1, funcref6.import_module t1, env7.import_name t1, t8.globl t19 10# Same import module/name/type as `t1`, should be de-duped.11.tabletype t2, funcref12.import_module t2, env13.import_name t2, t14.globl t215 16# Imported as an externref instead of funcref, so should not be de-duped.17.tabletype t3, externref18.import_module t3, env19.import_name t3, t20.globl t321 22.globl _start23_start:24 .functype _start () -> ()25 26 # Read from `t1`27 i32.const 028 table.get t129 drop30 31 # Read from `t2`32 i32.const 033 table.get t234 drop35 36 # Read from `t3`37 i32.const 038 table.get t339 drop40 41 end_function42 43## XXX: the second imported table has index 1, not 0. I've verified by hand44## (with `wasm2wat`) that the resulting Wasm file is correct: `t3` does end up45## at index 1 and our `table.get` instructions are using the proper table index46## immediates. This is also asserted (less legibly) in the hexdump of the code47## body below. It looks like there's a bug in how `obj2yaml` disassembles48## multiple table imports.49 50# CHECK: - Type: IMPORT51# CHECK-NEXT: Imports:52# CHECK-NEXT: - Module: env53# CHECK-NEXT: Field: t54# CHECK-NEXT: Kind: TABLE55# CHECK-NEXT: Table:56# CHECK-NEXT: Index: 057# CHECK-NEXT: ElemType: FUNCREF58# CHECK-NEXT: Limits:59# CHECK-NEXT: Minimum: 0x060# CHECK-NEXT: - Module: env61# CHECK-NEXT: Field: t62# CHECK-NEXT: Kind: TABLE63# CHECK-NEXT: Table:64# CHECK-NEXT: Index: 065# CHECK-NEXT: ElemType: EXTERNREF66# CHECK-NEXT: Limits:67# CHECK-NEXT: Minimum: 0x068# CHECK-NEXT: - Type:69 70# CHECK: - Type: CODE71# CHECK-NEXT: Functions:72# CHECK-NEXT: - Index: 073# CHECK-NEXT: Locals: []74# CHECK-NEXT: Body: 41002580808080001A41002580808080001A41002581808080001A0B75# CHECK-NEXT: - Type:76