Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / wasm / duplicate-table-imports.s
blobaa3307e221824493296d020e23325815461fcdaa
1 # RUN: llvm-mc -mattr=+reference-types -triple=wasm32-unknown-unknown -filetype=obj -o %t.o %s
2 # RUN: wasm-ld --allow-undefined -o %t1.wasm %t.o
3 # RUN: obj2yaml %t1.wasm | FileCheck %s
5 .tabletype t1, funcref
6 .import_module t1, env
7 .import_name t1, t
8 .globl t1
10 # Same import module/name/type as `t1`, should be de-duped.
11 .tabletype t2, funcref
12 .import_module t2, env
13 .import_name t2, t
14 .globl t2
16 # Imported as an externref instead of funcref, so should not be de-duped.
17 .tabletype t3, externref
18 .import_module t3, env
19 .import_name t3, t
20 .globl t3
22 .globl _start
23 _start:
24 .functype _start () -> ()
26 # Read from `t1`
27 i32.const 0
28 table.get t1
29 drop
31 # Read from `t2`
32 i32.const 0
33 table.get t2
34 drop
36 # Read from `t3`
37 i32.const 0
38 table.get t3
39 drop
41 end_function
43 ## XXX: the second imported table has index 1, not 0. I've verified by hand
44 ## (with `wasm2wat`) that the resulting Wasm file is correct: `t3` does end up
45 ## at index 1 and our `table.get` instructions are using the proper table index
46 ## immediates. This is also asserted (less legibly) in the hexdump of the code
47 ## body below. It looks like there's a bug in how `obj2yaml` disassembles
48 ## multiple table imports.
50 # CHECK: - Type: IMPORT
51 # CHECK-NEXT: Imports:
52 # CHECK-NEXT: - Module: env
53 # CHECK-NEXT: Field: t
54 # CHECK-NEXT: Kind: TABLE
55 # CHECK-NEXT: Table:
56 # CHECK-NEXT: Index: 0
57 # CHECK-NEXT: ElemType: FUNCREF
58 # CHECK-NEXT: Limits:
59 # CHECK-NEXT: Minimum: 0x0
60 # CHECK-NEXT: - Module: env
61 # CHECK-NEXT: Field: t
62 # CHECK-NEXT: Kind: TABLE
63 # CHECK-NEXT: Table:
64 # CHECK-NEXT: Index: 0
65 # CHECK-NEXT: ElemType: EXTERNREF
66 # CHECK-NEXT: Limits:
67 # CHECK-NEXT: Minimum: 0x0
68 # CHECK-NEXT: - Type:
70 # CHECK: - Type: CODE
71 # CHECK-NEXT: Functions:
72 # CHECK-NEXT: - Index: 0
73 # CHECK-NEXT: Locals: []
74 # CHECK-NEXT: Body: 41002580808080001A41002580808080001A41002581808080001A0B
75 # CHECK-NEXT: - Type: