Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / WebAssembly / reloc-pic64.s
blob0f2ebba2a2f33d87713440cefe3203801dd0a5cf
1 # RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck %s
2 # RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+reference-types -filetype=obj < %s | obj2yaml | FileCheck --check-prefix=REF %s
4 # Verify that @GOT relocation entries result in R_WASM_GLOBAL_INDEX_LEB against
5 # against the corrsponding function or data symbol and that the corresponding
6 # data symbols are imported as a wasm globals.
8 .functype default_func () -> (i32)
10 .globaltype __memory_base, i64
11 .globaltype __table_base, i64
13 load_default_data:
14 .functype load_default_data () -> (i32)
15 global.get default_data@GOT
16 i32.load 0
17 end_function
19 load_default_func:
20 .functype load_default_func () -> (i32)
21 global.get default_func@GOT
22 i32.load 0
23 end_function
25 load_hidden_data:
26 .functype load_hidden_data () -> (i64)
27 global.get __memory_base
28 i64.const .L.hidden_data@MBREL
29 i64.add
30 end_function
32 load_hidden_func:
33 .functype load_hidden_func () -> (i64)
34 global.get __table_base
35 i64.const hidden_func@TBREL
36 i64.add
37 end_function
39 hidden_func:
40 .functype hidden_func () -> (i32)
41 i32.const 0
42 end_function
44 .section .rodata.hidden_data,"",@
45 .L.hidden_data:
46 .int8 100
47 .size .L.hidden_data, 1
49 #.hidden hidden_func
50 #.hidden hidden_data
51 .size default_data, 4
53 # CHECK: --- !WASM
54 # CHECK-NEXT: FileHeader:
55 # CHECK-NEXT: Version: 0x1
56 # CHECK-NEXT: Sections:
57 # CHECK-NEXT: - Type: TYPE
58 # CHECK-NEXT: Signatures:
59 # CHECK-NEXT: - Index: 0
60 # CHECK-NEXT: ParamTypes: []
61 # CHECK-NEXT: ReturnTypes:
62 # CHECK-NEXT: - I32
63 # CHECK-NEXT: - Index: 1
64 # CHECK-NEXT: ParamTypes: []
65 # CHECK-NEXT: ReturnTypes:
66 # CHECK-NEXT: - I64
67 # CHECK-NEXT: - Type: IMPORT
68 # CHECK-NEXT: Imports:
69 # CHECK-NEXT: - Module: env
70 # CHECK-NEXT: Field: __linear_memory
71 # CHECK-NEXT: Kind: MEMORY
72 # CHECK-NEXT: Memory:
73 # CHECK-NEXT: Flags: [ IS_64 ]
74 # CHECK-NEXT: Minimum: 0x1
75 # CHECK-NEXT: - Module: env
76 # CHECK-NEXT: Field: default_func
77 # CHECK-NEXT: Kind: FUNCTION
78 # CHECK-NEXT: SigIndex: 0
79 # CHECK-NEXT: - Module: env
80 # CHECK-NEXT: Field: __memory_base
81 # CHECK-NEXT: Kind: GLOBAL
82 # CHECK-NEXT: GlobalType: I64
83 # CHECK-NEXT: GlobalMutable: true
84 # CHECK-NEXT: - Module: env
85 # CHECK-NEXT: Field: __table_base
86 # CHECK-NEXT: Kind: GLOBAL
87 # CHECK-NEXT: GlobalType: I64
88 # CHECK-NEXT: GlobalMutable: true
89 # CHECK-NEXT: - Module: env
90 # CHECK-NEXT: Field: __indirect_function_table
91 # CHECK-NEXT: Kind: TABLE
92 # CHECK-NEXT: Table:
93 # CHECK-NEXT: Index: 0
94 # CHECK-NEXT: ElemType: FUNCREF
95 # CHECK-NEXT: Limits:
96 # CHECK-NEXT: Minimum: 0x1
97 # CHECK-NEXT: - Module: GOT.mem
98 # CHECK-NEXT: Field: default_data
99 # CHECK-NEXT: Kind: GLOBAL
100 # CHECK-NEXT: GlobalType: I32
101 # CHECK-NEXT: GlobalMutable: true
102 # CHECK-NEXT: - Module: GOT.func
103 # CHECK-NEXT: Field: default_func
104 # CHECK-NEXT: Kind: GLOBAL
105 # CHECK-NEXT: GlobalType: I32
106 # CHECK-NEXT: GlobalMutable: true
107 # CHECK-NEXT: - Type: FUNCTION
108 # CHECK-NEXT: FunctionTypes: [ 0, 0, 1, 1, 0 ]
109 # CHECK-NEXT: - Type: ELEM
110 # CHECK-NEXT: Segments:
111 # CHECK-NEXT: Offset:
112 # CHECK-NEXT: Opcode: I32_CONST
113 # CHECK-NEXT: Value: 1
114 # CHECK-NEXT: Functions: [ 5 ]
115 # CHECK-NEXT: - Type: DATACOUNT
116 # CHECK-NEXT: Count: 1
117 # CHECK-NEXT: - Type: CODE
118 # CHECK-NEXT: Relocations:
119 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
120 # CHECK-NEXT: Index: 1
121 # CHECK-NEXT: Offset: 0x4
122 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
123 # CHECK-NEXT: Index: 3
124 # CHECK-NEXT: Offset: 0x10
125 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
126 # CHECK-NEXT: Index: 5
127 # CHECK-NEXT: Offset: 0x1C
128 # CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_REL_SLEB64
129 # CHECK-NEXT: Index: 6
130 # CHECK-NEXT: Offset: 0x22
131 # CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
132 # CHECK-NEXT: Index: 8
133 # CHECK-NEXT: Offset: 0x31
134 # CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_REL_SLEB64
135 # CHECK-NEXT: Index: 9
136 # CHECK-NEXT: Offset: 0x37
137 # CHECK-NEXT: Functions:
138 # CHECK-NEXT: - Index: 1
139 # CHECK-NEXT: Locals: []
140 # CHECK-NEXT: Body: 2382808080002802000B
141 # CHECK-NEXT: - Index: 2
142 # CHECK-NEXT: Locals: []
143 # CHECK-NEXT: Body: 2383808080002802000B
144 # CHECK-NEXT: - Index: 3
145 # CHECK-NEXT: Locals: []
146 # CHECK-NEXT: Body: 23808080800042808080808080808080007C0B
147 # CHECK-NEXT: - Index: 4
148 # CHECK-NEXT: Locals: []
149 # CHECK-NEXT: Body: 23818080800042808080808080808080007C0B
150 # CHECK-NEXT: - Index: 5
151 # CHECK-NEXT: Locals: []
152 # CHECK-NEXT: Body: 41000B
153 # CHECK-NEXT: - Type: DATA
154 # CHECK-NEXT: Segments:
155 # CHECK-NEXT: - SectionOffset: 6
156 # CHECK-NEXT: InitFlags: 0
157 # CHECK-NEXT: Offset:
158 # CHECK-NEXT: Opcode: I64_CONST
159 # CHECK-NEXT: Value: 0
160 # CHECK-NEXT: Content: '64'
161 # CHECK-NEXT: - Type: CUSTOM
162 # CHECK-NEXT: Name: linking
163 # CHECK-NEXT: Version: 2
164 # CHECK-NEXT: SymbolTable:
165 # CHECK-NEXT: - Index: 0
166 # CHECK-NEXT: Kind: FUNCTION
167 # CHECK-NEXT: Name: load_default_data
168 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
169 # CHECK-NEXT: Function: 1
170 # CHECK-NEXT: - Index: 1
171 # CHECK-NEXT: Kind: DATA
172 # CHECK-NEXT: Name: default_data
173 # CHECK-NEXT: Flags: [ UNDEFINED ]
174 # CHECK-NEXT: - Index: 2
175 # CHECK-NEXT: Kind: FUNCTION
176 # CHECK-NEXT: Name: load_default_func
177 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
178 # CHECK-NEXT: Function: 2
179 # CHECK-NEXT: - Index: 3
180 # CHECK-NEXT: Kind: FUNCTION
181 # CHECK-NEXT: Name: default_func
182 # CHECK-NEXT: Flags: [ UNDEFINED ]
183 # CHECK-NEXT: Function: 0
184 # CHECK-NEXT: - Index: 4
185 # CHECK-NEXT: Kind: FUNCTION
186 # CHECK-NEXT: Name: load_hidden_data
187 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
188 # CHECK-NEXT: Function: 3
189 # CHECK-NEXT: - Index: 5
190 # CHECK-NEXT: Kind: GLOBAL
191 # CHECK-NEXT: Name: __memory_base
192 # CHECK-NEXT: Flags: [ UNDEFINED ]
193 # CHECK-NEXT: Global: 0
194 # CHECK-NEXT: - Index: 6
195 # CHECK-NEXT: Kind: DATA
196 # CHECK-NEXT: Name: .L.hidden_data
197 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
198 # CHECK-NEXT: Segment: 0
199 # CHECK-NEXT: Size: 1
200 # CHECK-NEXT: - Index: 7
201 # CHECK-NEXT: Kind: FUNCTION
202 # CHECK-NEXT: Name: load_hidden_func
203 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
204 # CHECK-NEXT: Function: 4
205 # CHECK-NEXT: - Index: 8
206 # CHECK-NEXT: Kind: GLOBAL
207 # CHECK-NEXT: Name: __table_base
208 # CHECK-NEXT: Flags: [ UNDEFINED ]
209 # CHECK-NEXT: Global: 1
210 # CHECK-NEXT: - Index: 9
211 # CHECK-NEXT: Kind: FUNCTION
212 # CHECK-NEXT: Name: hidden_func
213 # CHECK-NEXT: Flags: [ BINDING_LOCAL ]
214 # CHECK-NEXT: Function: 5
215 # REF: - Index: 10
216 # REF-NEXT: Kind: TABLE
217 # REF-NEXT: Name: __indirect_function_table
218 # REF-NEXT: Flags: [ UNDEFINED, NO_STRIP ]
219 # REF-NEXT: Table: 0
220 # CHECK-NEXT: SegmentInfo:
221 # CHECK-NEXT: - Index: 0
222 # CHECK-NEXT: Name: .rodata.hidden_data
223 # CHECK-NEXT: Alignment: 0
224 # CHECK-NEXT: Flags: [ ]
225 # CHECK-NEXT: ...