Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / wasm / mutable-global-exports.s
blob135559d5249bcd170d33df5f46824bb9ed3585d7
1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
3 # Should fail without mutable globals feature enabled.
4 # RUN: not wasm-ld --export-all %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-ERR %s
5 # RUN: not wasm-ld --export=foo_global %t.o -o %t.wasm 2>&1 | FileCheck -check-prefix=CHECK-ERR %s
7 # RUN: wasm-ld --extra-features=mutable-globals --export=foo_global %t.o -o %t.wasm
8 # RUN: obj2yaml %t.wasm | FileCheck %s
10 # Explcitly check that __stack_pointer can be exported
11 # RUN: wasm-ld --extra-features=mutable-globals --export=__stack_pointer %t.o -o %t.wasm
12 # RUN: obj2yaml %t.wasm | FileCheck -check-prefix=CHECK-SP %s
14 # RUN: wasm-ld --extra-features=mutable-globals --export-all %t.o -o %t.wasm
15 # RUN: obj2yaml %t.wasm | FileCheck -check-prefix=CHECK-ALL %s
17 .globl _start
18 .globl foo_global
20 .globaltype foo_global, i32
21 foo_global:
23 _start:
24 .functype _start () -> ()
25 end_function
27 # Add a target feature and ensure that it is preserved when --extra-features is
28 # used above.
29 .section .custom_section.target_features,"",@
30 .int8 1
31 .int8 43
32 .int8 7
33 .ascii "atomics"
35 # CHECK-ERR: mutable global exported but 'mutable-globals' feature not present in inputs: `foo_global`. Use --no-check-features to suppress
37 # CHECK: - Type: EXPORT
38 # CHECK-NEXT: Exports:
39 # CHECK-NEXT: - Name: memory
40 # CHECK-NEXT: Kind: MEMORY
41 # CHECK-NEXT: Index: 0
42 # CHECK-NEXT: - Name: _start
43 # CHECK-NEXT: Kind: FUNCTION
44 # CHECK-NEXT: Index: 0
45 # CHECK-NEXT: - Name: foo_global
46 # CHECK-NEXT: Kind: GLOBAL
47 # CHECK-NEXT: Index: 1
48 # CHECK-NEXT: - Type: CODE
50 # CHECK-SP: - Type: EXPORT
51 # CHECK-SP-NEXT: Exports:
52 # CHECK-SP-NEXT: - Name: memory
53 # CHECK-SP-NEXT: Kind: MEMORY
54 # CHECK-SP-NEXT: Index: 0
55 # CHECK-SP-NEXT: - Name: __stack_pointer
56 # CHECK-SP-NEXT: Kind: GLOBAL
57 # CHECK-SP-NEXT: Index: 0
58 # CHECK-SP-NEXT: - Name: _start
59 # CHECK-SP-NEXT: Kind: FUNCTION
60 # CHECK-SP-NEXT: Index: 0
61 # CHECK-SP-NEXT: - Type: CODE
63 # CHECK-ALL: - Type: EXPORT
64 # CHECK-ALL-NEXT: Exports:
65 # CHECK-ALL-NEXT: - Name: memory
66 # CHECK-ALL-NEXT: Kind: MEMORY
67 # CHECK-ALL-NEXT: Index: 0
68 # CHECK-ALL-NEXT: - Name: __wasm_call_ctors
69 # CHECK-ALL-NEXT: Kind: FUNCTION
70 # CHECK-ALL-NEXT: Index: 0
71 # CHECK-ALL-NEXT: - Name: _start
72 # CHECK-ALL-NEXT: Kind: FUNCTION
73 # CHECK-ALL-NEXT: Index: 1
74 # CHECK-ALL-NEXT: - Name: foo_global
75 # CHECK-ALL-NEXT: Kind: GLOBAL
76 # CHECK-ALL-NEXT: Index: 1
77 # CHECK-ALL-NEXT: - Name: __dso_handle
78 # CHECK-ALL-NEXT: Kind: GLOBAL
79 # CHECK-ALL-NEXT: Index: 2
80 # CHECK-ALL-NEXT: - Name: __data_end
81 # CHECK-ALL-NEXT: Kind: GLOBAL
82 # CHECK-ALL-NEXT: Index: 3
83 # CHECK-ALL-NEXT: - Name: __stack_low
84 # CHECK-ALL-NEXT: Kind: GLOBAL
85 # CHECK-ALL-NEXT: Index: 4
86 # CHECK-ALL-NEXT: - Name: __stack_high
87 # CHECK-ALL-NEXT: Kind: GLOBAL
88 # CHECK-ALL-NEXT: Index: 5
89 # CHECK-ALL-NEXT: - Name: __global_base
90 # CHECK-ALL-NEXT: Kind: GLOBAL
91 # CHECK-ALL-NEXT: Index: 6
92 # CHECK-ALL-NEXT: - Name: __heap_base
93 # CHECK-ALL-NEXT: Kind: GLOBAL
94 # CHECK-ALL-NEXT: Index: 7
95 # CHECK-ALL-NEXT: - Name: __heap_end
96 # CHECK-ALL-NEXT: Kind: GLOBAL
97 # CHECK-ALL-NEXT: Index: 8
98 # CHECK-ALL-NEXT: - Name: __memory_base
99 # CHECK-ALL-NEXT: Kind: GLOBAL
100 # CHECK-ALL-NEXT: Index: 9
101 # CHECK-ALL-NEXT: - Name: __table_base
102 # CHECK-ALL-NEXT: Kind: GLOBAL
103 # CHECK-ALL-NEXT: Index: 10
104 # CHECK-ALL-NEXT: - Type: CODE
106 # CHECK-ALL: Name: target_features
107 # CHECK-ALL-NEXT: Features:
108 # CHECK-ALL-NEXT: - Prefix: USED
109 # CHECK-ALL-NEXT: Name: atomics
110 # CHECK-ALL-NEXT: - Prefix: USED
111 # CHECK-ALL-NEXT: Name: mutable-globals
112 # CHECK-ALL-NEXT: ...