[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / wasm / weak-alias.ll
blob1768b8fd5b385125d6e95272b644a052f1a10451
1 ; RUN: llc -mcpu=mvp -filetype=obj -o %t.o %s
2 ; RUN: llc -mcpu=mvp -filetype=obj %S/Inputs/weak-alias.ll -o %t2.o
3 ; RUN: wasm-ld --export-dynamic %t.o %t2.o -o %t.wasm
4 ; RUN: obj2yaml %t.wasm | FileCheck %s
6 ; Test that weak aliases (alias_fn is a weak alias of direct_fn) are linked correctly
8 target triple = "wasm32-unknown-unknown"
10 declare i32 @alias_fn() local_unnamed_addr #1
12 ; Function Attrs: nounwind uwtable
13 define void @_start() local_unnamed_addr #1 {
14 entry:
15   %call = tail call i32 @alias_fn() #2
16   ret void
19 ; CHECK:      --- !WASM
20 ; CHECK-NEXT: FileHeader:
21 ; CHECK-NEXT:   Version:         0x1
22 ; CHECK-NEXT: Sections:
23 ; CHECK-NEXT:   - Type:            TYPE
24 ; CHECK-NEXT:     Signatures:
25 ; CHECK-NEXT:       - Index:           0
26 ; CHECK-NEXT:         ParamTypes:
27 ; CHECK-NEXT:         ReturnTypes:     []
28 ; CHECK-NEXT:       - Index:           1
29 ; CHECK-NEXT:         ParamTypes:      []
30 ; CHECK-NEXT:         ReturnTypes:
31 ; CHECK-NEXT:           - I32
32 ; CHECK-NEXT:   - Type:            FUNCTION
33 ; CHECK-NEXT:     FunctionTypes:   [ 0, 1, 1, 1, 1, 1 ]
34 ; CHECK-NEXT:   - Type:            TABLE
35 ; CHECK-NEXT:     Tables:
36 ; CHECK-NEXT:       - Index:           0
37 ; CHECK-NEXT:         ElemType:        FUNCREF
38 ; CHECK-NEXT:         Limits:
39 ; CHECK-NEXT:           Flags:           [ HAS_MAX ]
40 ; CHECK-NEXT:           Minimum:         0x2
41 ; CHECK-NEXT:           Maximum:         0x2
42 ; CHECK-NEXT:   - Type:            MEMORY
43 ; CHECK-NEXT:     Memories:
44 ; CHECK-NEXT:       - Minimum:         0x2
45 ; CHECK-NEXT:   - Type:            GLOBAL
46 ; CHECK-NEXT:     Globals:
47 ; CHECK-NEXT:       - Index:           0
48 ; CHECK-NEXT:         Type:            I32
49 ; CHECK-NEXT:         Mutable:         true
50 ; CHECK-NEXT:         InitExpr:
51 ; CHECK-NEXT:           Opcode:          I32_CONST
52 ; CHECK-NEXT:           Value:           66560
53 ; CHECK-NEXT:   - Type:            EXPORT
54 ; CHECK-NEXT:     Exports:
55 ; CHECK-NEXT:       - Name:            memory
56 ; CHECK-NEXT:         Kind:            MEMORY
57 ; CHECK-NEXT:         Index:           0
58 ; CHECK-NEXT:       - Name:            _start
59 ; CHECK-NEXT:         Kind:            FUNCTION
60 ; CHECK-NEXT:         Index:           0
61 ; CHECK-NEXT:       - Name:            alias_fn
62 ; CHECK-NEXT:         Kind:            FUNCTION
63 ; CHECK-NEXT:         Index:           1
64 ; CHECK-NEXT:       - Name:            direct_fn
65 ; CHECK-NEXT:         Kind:            FUNCTION
66 ; CHECK-NEXT:         Index:           1
67 ; CHECK-NEXT:       - Name:            call_direct
68 ; CHECK-NEXT:         Kind:            FUNCTION
69 ; CHECK-NEXT:         Index:           2
70 ; CHECK-NEXT:       - Name:            call_alias
71 ; CHECK-NEXT:         Kind:            FUNCTION
72 ; CHECK-NEXT:         Index:           3
73 ; CHECK-NEXT:       - Name:            call_alias_ptr
74 ; CHECK-NEXT:         Kind:            FUNCTION
75 ; CHECK-NEXT:         Index:           4
76 ; CHECK-NEXT:       - Name:            call_direct_ptr
77 ; CHECK-NEXT:         Kind:            FUNCTION
78 ; CHECK-NEXT:         Index:           5
79 ; CHECK-NEXT:   - Type:            ELEM
80 ; CHECK-NEXT:     Segments:
81 ; CHECK-NEXT:       - Offset:
82 ; CHECK-NEXT:           Opcode:          I32_CONST
83 ; CHECK-NEXT:           Value:           1
84 ; CHECK-NEXT:         Functions:       [ 1 ]
85 ; CHECK-NEXT:   - Type:            CODE
86 ; CHECK-NEXT:     Functions:
87 ; CHECK-NEXT:       - Index:           0
88 ; CHECK-NEXT:         Locals:
89 ; CHECK-NEXT:         Body:            1081808080001A0B
90 ; CHECK-NEXT:       - Index:           1
91 ; CHECK-NEXT:         Locals:
92 ; CHECK-NEXT:         Body:            41000B
93 ; CHECK-NEXT:       - Index:           2
94 ; CHECK-NEXT:         Locals:
95 ; CHECK-NEXT:         Body:            1081808080000B
96 ; CHECK-NEXT:       - Index:           3
97 ; CHECK-NEXT:         Locals:
98 ; CHECK-NEXT:         Body:            1081808080000B
99 ; CHECK-NEXT:       - Index:           4
100 ; CHECK-NEXT:         Locals:
101 ; CHECK-NEXT:           - Type:            I32
102 ; CHECK-NEXT:             Count:           2
103 ; CHECK-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B
104 ; CHECK-NEXT:       - Index:           5
105 ; CHECK-NEXT:         Locals:
106 ; CHECK-NEXT:           - Type:            I32
107 ; CHECK-NEXT:             Count:           2
108 ; CHECK-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B
109 ; CHECK-NEXT:   - Type:            CUSTOM
110 ; CHECK-NEXT:     HeaderSecSizeEncodingLen: 2
111 ; CHECK-NEXT:     Name:            name
112 ; CHECK-NEXT:     FunctionNames:
113 ; CHECK-NEXT:       - Index:           0
114 ; CHECK-NEXT:         Name:            _start
115 ; CHECK-NEXT:       - Index:           1
116 ; CHECK-NEXT:         Name:            direct_fn
117 ; CHECK-NEXT:       - Index:           2
118 ; CHECK-NEXT:         Name:            call_direct
119 ; CHECK-NEXT:       - Index:           3
120 ; CHECK-NEXT:         Name:            call_alias
121 ; CHECK-NEXT:       - Index:           4
122 ; CHECK-NEXT:         Name:            call_alias_ptr
123 ; CHECK-NEXT:       - Index:           5
124 ; CHECK-NEXT:         Name:            call_direct_ptr
125 ; CHECK-NEXT:     GlobalNames:
126 ; CHECK-NEXT:       - Index:           0
127 ; CHECK-NEXT:         Name:            __stack_pointer
128 ; CHECK-NEXT: ...
130 ; RUN: wasm-ld --relocatable %t.o %t2.o -o %t.reloc.o
131 ; RUN: obj2yaml %t.reloc.o | FileCheck %s -check-prefix=RELOC
133 ; RELOC:      --- !WASM
134 ; RELOC-NEXT: FileHeader:
135 ; RELOC-NEXT:   Version:         0x1
136 ; RELOC-NEXT: Sections:
137 ; RELOC-NEXT:   - Type:            TYPE
138 ; RELOC-NEXT:     Signatures:
139 ; RELOC-NEXT:       - Index:           0
140 ; RELOC-NEXT:         ParamTypes:      []
141 ; RELOC-NEXT:         ReturnTypes:     []
142 ; RELOC-NEXT:       - Index:           1
143 ; RELOC-NEXT:         ParamTypes:      []
144 ; RELOC-NEXT:         ReturnTypes:
145 ; RELOC-NEXT:           - I32
146 ; RELOC-NEXT:   - Type:            IMPORT
147 ; RELOC-NEXT:     Imports:
148 ; RELOC-NEXT:       - Module:          env
149 ; RELOC-NEXT:         Field:           __indirect_function_table
150 ; RELOC-NEXT:         Kind:            TABLE
151 ; RELOC-NEXT:         Table:
152 ; RELOC-NEXT:           Index:           0
153 ; RELOC-NEXT:           ElemType:        FUNCREF
154 ; RELOC-NEXT:           Limits:
155 ; RELOC-NEXT:             Minimum:         0x2
156 ; RELOC-NEXT:       - Module:          env
157 ; RELOC-NEXT:         Field:           __stack_pointer
158 ; RELOC-NEXT:         Kind:            GLOBAL
159 ; RELOC-NEXT:         GlobalType:      I32
160 ; RELOC-NEXT:         GlobalMutable:   true
161 ; RELOC-NEXT:   - Type:            FUNCTION
162 ; RELOC-NEXT:     FunctionTypes:   [ 0, 1, 1, 1, 1, 1 ]
163 ; RELOC-NEXT:   - Type:            MEMORY
164 ; RELOC-NEXT:     Memories:
165 ; RELOC-NEXT:       - Minimum:         0x0
166 ; RELOC-NEXT:   - Type:            ELEM
167 ; RELOC-NEXT:     Segments:
168 ; RELOC-NEXT:       - Offset:
169 ; RELOC-NEXT:           Opcode:          I32_CONST
170 ; RELOC-NEXT:           Value:           1
171 ; RELOC-NEXT:         Functions:       [ 1 ]
172 ; RELOC-NEXT:   - Type:            CODE
173 ; RELOC-NEXT:     Relocations:
174 ; RELOC-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
175 ; RELOC-NEXT:         Index:           1
176 ; RELOC-NEXT:         Offset:          0x4
177 ; RELOC-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
178 ; RELOC-NEXT:         Index:           2
179 ; RELOC-NEXT:         Offset:          0x13
180 ; RELOC-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
181 ; RELOC-NEXT:         Index:           1
182 ; RELOC-NEXT:         Offset:          0x1C
183 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
184 ; RELOC-NEXT:         Index:           6
185 ; RELOC-NEXT:         Offset:          0x27
186 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
187 ; RELOC-NEXT:         Index:           6
188 ; RELOC-NEXT:         Offset:          0x32
189 ; RELOC-NEXT:       - Type:            R_WASM_TABLE_INDEX_SLEB
190 ; RELOC-NEXT:         Index:           1
191 ; RELOC-NEXT:         Offset:          0x3A
192 ; RELOC-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
193 ; RELOC-NEXT:         Index:           1
194 ; RELOC-NEXT:         Offset:          0x43
195 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
196 ; RELOC-NEXT:         Index:           6
197 ; RELOC-NEXT:         Offset:          0x50
198 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
199 ; RELOC-NEXT:         Index:           6
200 ; RELOC-NEXT:         Offset:          0x5D
201 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
202 ; RELOC-NEXT:         Index:           6
203 ; RELOC-NEXT:         Offset:          0x68
204 ; RELOC-NEXT:       - Type:            R_WASM_TABLE_INDEX_SLEB
205 ; RELOC-NEXT:         Index:           2
206 ; RELOC-NEXT:         Offset:          0x70
207 ; RELOC-NEXT:       - Type:            R_WASM_FUNCTION_INDEX_LEB
208 ; RELOC-NEXT:         Index:           2
209 ; RELOC-NEXT:         Offset:          0x79
210 ; RELOC-NEXT:       - Type:            R_WASM_GLOBAL_INDEX_LEB
211 ; RELOC-NEXT:         Index:           6
212 ; RELOC-NEXT:         Offset:          0x86
213 ; RELOC-NEXT:     Functions:
214 ; RELOC-NEXT:       - Index:           0
215 ; RELOC-NEXT:         Locals:
216 ; RELOC-NEXT:         Body:            1081808080001A0B
217 ; RELOC-NEXT:       - Index:           1
218 ; RELOC-NEXT:         Locals:
219 ; RELOC-NEXT:         Body:            41000B
220 ; RELOC-NEXT:       - Index:           2
221 ; RELOC-NEXT:         Locals:
222 ; RELOC-NEXT:         Body:            1081808080000B
223 ; RELOC-NEXT:       - Index:           3
224 ; RELOC-NEXT:         Locals:
225 ; RELOC-NEXT:         Body:            1081808080000B
226 ; RELOC-NEXT:       - Index:           4
227 ; RELOC-NEXT:         Locals:
228 ; RELOC-NEXT:           - Type:            I32
229 ; RELOC-NEXT:             Count:           2
230 ; RELOC-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B
231 ; RELOC-NEXT:       - Index:           5
232 ; RELOC-NEXT:         Locals:
233 ; RELOC-NEXT:           - Type:            I32
234 ; RELOC-NEXT:             Count:           2
235 ; RELOC-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B
236 ; RELOC-NEXT:   - Type:            CUSTOM
237 ; RELOC-NEXT:     Name:            linking
238 ; RELOC-NEXT:     Version:         2
239 ; RELOC-NEXT:     SymbolTable:
240 ; RELOC-NEXT:       - Index:           0
241 ; RELOC-NEXT:         Kind:            FUNCTION
242 ; RELOC-NEXT:         Name:            _start
243 ; RELOC-NEXT:         Flags:           [  ]
244 ; RELOC-NEXT:         Function:        0
245 ; RELOC-NEXT:       - Index:           1
246 ; RELOC-NEXT:         Kind:            FUNCTION
247 ; RELOC-NEXT:         Name:            alias_fn
248 ; RELOC-NEXT:         Flags:           [ BINDING_WEAK ]
249 ; RELOC-NEXT:         Function:        1
250 ; RELOC-NEXT:       - Index:           2
251 ; RELOC-NEXT:         Kind:            FUNCTION
252 ; RELOC-NEXT:         Name:            direct_fn
253 ; RELOC-NEXT:         Flags:           [  ]
254 ; RELOC-NEXT:         Function:        1
255 ; RELOC-NEXT:       - Index:           3
256 ; RELOC-NEXT:         Kind:            FUNCTION
257 ; RELOC-NEXT:         Name:            call_direct
258 ; RELOC-NEXT:         Flags:           [  ]
259 ; RELOC-NEXT:         Function:        2
260 ; RELOC-NEXT:       - Index:           4
261 ; RELOC-NEXT:         Kind:            FUNCTION
262 ; RELOC-NEXT:         Name:            call_alias
263 ; RELOC-NEXT:         Flags:           [  ]
264 ; RELOC-NEXT:         Function:        3
265 ; RELOC-NEXT:       - Index:           5
266 ; RELOC-NEXT:         Kind:            FUNCTION
267 ; RELOC-NEXT:         Name:            call_alias_ptr
268 ; RELOC-NEXT:         Flags:           [  ]
269 ; RELOC-NEXT:         Function:        4
270 ; RELOC-NEXT:       - Index:           6
271 ; RELOC-NEXT:         Kind:            GLOBAL
272 ; RELOC-NEXT:         Name:            __stack_pointer
273 ; RELOC-NEXT:         Flags:           [ UNDEFINED ]
274 ; RELOC-NEXT:         Global:          0
275 ; RELOC-NEXT:       - Index:           7
276 ; RELOC-NEXT:         Kind:            FUNCTION
277 ; RELOC-NEXT:         Name:            call_direct_ptr
278 ; RELOC-NEXT:         Flags:           [  ]
279 ; RELOC-NEXT:         Function:        5
280 ; RELOC-NEXT:       - Index:           8
281 ; RELOC-NEXT:         Kind:            TABLE
282 ; RELOC-NEXT:         Name:            __indirect_function_table
283 ; RELOC-NEXT:         Flags:           [ UNDEFINED, NO_STRIP ]
284 ; RELOC-NEXT:         Table:           0
285 ; RELOC-NEXT:   - Type:            CUSTOM
286 ; RELOC-NEXT:     Name:            name
287 ; RELOC-NEXT:     FunctionNames:
288 ; RELOC-NEXT:       - Index:           0
289 ; RELOC-NEXT:         Name:            _start
290 ; RELOC-NEXT:       - Index:           1
291 ; RELOC-NEXT:         Name:            direct_fn
292 ; RELOC-NEXT:       - Index:           2
293 ; RELOC-NEXT:         Name:            call_direct
294 ; RELOC-NEXT:       - Index:           3
295 ; RELOC-NEXT:         Name:            call_alias
296 ; RELOC-NEXT:       - Index:           4
297 ; RELOC-NEXT:         Name:            call_alias_ptr
298 ; RELOC-NEXT:       - Index:           5
299 ; RELOC-NEXT:         Name:            call_direct_ptr
300 ; RELOC-NEXT:     GlobalNames:
301 ; RELOC-NEXT:       - Index:           0
302 ; RELOC-NEXT:         Name:            __stack_pointer
303 ; RELOC-NEXT: ...