[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / COFF / arm64ec-entry-thunk.s
blob164e6cc4396489ded532cbe93ea26f5e012cfe90
1 // REQUIRES: aarch64
2 // RUN: split-file %s %t.dir && cd %t.dir
4 #--- test-simple.s
5 // Build a simple function with an entry thunk.
7 .section .text,"xr",discard,func
8 .globl func
9 .p2align 2
10 func:
11 mov w0, #1
12 ret
14 .section .wowthk$aa,"xr",discard,thunk
15 .globl thunk
16 .p2align 2
17 thunk:
18 mov w0, #10
19 ret
21 .section .hybmp$x, "yi"
22 .symidx func
23 .symidx thunk
24 .word 1 // entry thunk
26 .data
27 .rva func
29 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadcfg.obj
30 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-simple.s -o test-simple.obj
31 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-simple.dll loadcfg.obj test-simple.obj
32 // RUN: llvm-objdump -d out-simple.dll | FileCheck --check-prefix=DISASM %s
34 // DISASM: Disassembly of section .text:
35 // DISASM-EMPTY:
36 // DISASM-NEXT: 0000000180001000 <.text>:
37 // DISASM-NEXT: 180001000: 00000009 udf #0x9
38 // DISASM-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
39 // DISASM-NEXT: 180001008: d65f03c0 ret
40 // DISASM-NEXT: 18000100c: 52800140 mov w0, #0xa // =10
41 // DISASM-NEXT: 180001010: d65f03c0 ret
43 // RUN: llvm-readobj --sections out-simple.dll | FileCheck --check-prefix=HYBMP %s
44 // HYBMP-NOT: .hybmp
46 // RUN: lld-link -machine:arm64x -dll -noentry -out:out-simplex.dll loadcfg.obj test-simple.obj
47 // RUN: llvm-objdump -d out-simplex.dll | FileCheck --check-prefix=DISASM %s
49 #--- test-split-func.s
50 // Build a simple function with an entry thunk, but pass it in multiple files.
52 .section .text,"xr",discard,func
53 .globl func
54 .p2align 2
55 func:
56 mov w0, #1
57 ret
59 #--- test-split-thunk.s
60 .section .wowthk$aa,"xr",discard,thunk
61 .globl thunk
62 .p2align 2
63 thunk:
64 mov w0, #10
65 ret
67 #--- test-split-hybmp.s
68 .section .hybmp$x, "yi"
69 .symidx func
70 .symidx thunk
71 .word 1 // entry thunk
73 #--- test-split-data.s
74 .data
75 .rva func
77 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-func.s -o test-split-func.obj
78 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-thunk.s -o test-split-thunk.obj
79 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-hybmp.s -o test-split-hybmp.obj
80 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-split-data.s -o test-split-data.obj
81 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-split.dll loadcfg.obj \
82 // RUN: test-split-func.obj test-split-thunk.obj test-split-data.obj test-split-hybmp.obj
83 // RUN: llvm-objdump -d out-split.dll | FileCheck --check-prefix=DISASM %s
85 #--- test-align.s
86 // Build multiple functions with thunks and various alignments and check that entry thunk offsets
87 // are correctly placed.
89 .section .text,"xr",discard,func
90 .globl func
91 .p2align 2
92 func:
93 mov w0, #1
94 nop
95 ret
97 .section .text,"xr",discard,func2
98 .globl func2
99 .p2align 2
100 func2:
101 mov w0, #2
104 .section .text,"xr",discard,func3
105 .globl func3
106 .p2align 3
107 func3:
108 mov w0, #3
112 .section .text,"xr",discard,func4
113 .globl func4
114 .p2align 3
115 func4:
116 mov w0, #4
119 .section .text,"xr",discard,func5
120 .globl func5
121 .p2align 3
122 func5:
123 mov w0, #5
126 .section .text,"xr",discard,func6
127 .globl func6
128 .p2align 4
129 func6:
130 mov w0, #6
133 .section .wowthk$aa,"xr",discard,thunk
134 .globl thunk
135 .p2align 2
136 thunk:
137 mov w0, #10
140 .section .wowthk$aa,"xr",discard,thunk2
141 .globl thunk2
142 .p2align 2
143 thunk2:
144 mov w0, #20
147 .section .hybmp$x, "yi"
148 .symidx func
149 .symidx thunk
150 .word 1 // entry thunk
151 .symidx func2
152 .symidx thunk2
153 .word 1 // entry thunk
154 .symidx func3
155 .symidx thunk
156 .word 1 // entry thunk
157 .symidx func4
158 .symidx thunk
159 .word 1 // entry thunk
160 .symidx func5
161 .symidx thunk
162 .word 1 // entry thunk
163 .symidx func6
164 .symidx thunk
165 .word 1 // entry thunk
167 .data
168 .rva func
169 .rva func2
170 .rva func3
171 .rva func4
172 .rva func5
173 .rva func6
175 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-align.s -o test-align.obj
176 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-align.dll loadcfg.obj test-align.obj
177 // RUN: llvm-objdump -d out-align.dll | FileCheck --check-prefix=ALIGN %s
179 // ALIGN: Disassembly of section .text:
180 // ALIGN-EMPTY:
181 // ALIGN-NEXT: 0000000180001000 <.text>:
182 // ALIGN-NEXT: 180001000: 00000055 udf #0x55
183 // ALIGN-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
184 // ALIGN-NEXT: 180001008: d503201f nop
185 // ALIGN-NEXT: 18000100c: d65f03c0 ret
186 // ALIGN-NEXT: 180001010: 0000004d udf #0x4d
187 // ALIGN-NEXT: 180001014: 52800040 mov w0, #0x2 // =2
188 // ALIGN-NEXT: 180001018: d65f03c0 ret
189 // ALIGN-NEXT: 18000101c: 00000039 udf #0x39
190 // ALIGN-NEXT: 180001020: 52800060 mov w0, #0x3 // =3
191 // ALIGN-NEXT: 180001024: d503201f nop
192 // ALIGN-NEXT: 180001028: d65f03c0 ret
193 // ALIGN-NEXT: 18000102c: 00000029 udf #0x29
194 // ALIGN-NEXT: 180001030: 52800080 mov w0, #0x4 // =4
195 // ALIGN-NEXT: 180001034: d65f03c0 ret
196 // ALIGN-NEXT: 180001038: 00000000 udf #0x0
197 // ALIGN-NEXT: 18000103c: 00000019 udf #0x19
198 // ALIGN-NEXT: 180001040: 528000a0 mov w0, #0x5 // =5
199 // ALIGN-NEXT: 180001044: d65f03c0 ret
200 // ALIGN-NEXT: 180001048: 00000000 udf #0x0
201 // ALIGN-NEXT: 18000104c: 00000009 udf #0x9
202 // ALIGN-NEXT: 180001050: 528000c0 mov w0, #0x6 // =6
203 // ALIGN-NEXT: 180001054: d65f03c0 ret
204 // ALIGN-NEXT: 180001058: 52800140 mov w0, #0xa // =10
205 // ALIGN-NEXT: 18000105c: d65f03c0 ret
206 // ALIGN-NEXT: 180001060: 52800280 mov w0, #0x14 // =20
207 // ALIGN-NEXT: 180001064: d65f03c0 ret
209 #--- test-icf-thunk.s
210 // Build two functions with identical entry thunks and check that thunks are merged by ICF.
212 .section .text,"xr",discard,func
213 .globl func
214 .p2align 2
215 func:
216 mov w0, #1
219 .section .text,"xr",discard,func2
220 .globl func2
221 .p2align 2
222 func2:
223 mov w0, #2
226 .section .wowthk$aa,"xr",discard,thunk
227 .globl thunk
228 .p2align 2
229 thunk:
230 mov w0, #10
233 .section .wowthk$aa,"xr",discard,thunk2
234 .globl thunk2
235 .p2align 2
236 thunk2:
237 mov w0, #10
240 .section .hybmp$x, "yi"
241 .symidx func
242 .symidx thunk
243 .word 1 // entry thunk
244 .symidx func2
245 .symidx thunk2
246 .word 1 // entry thunk
248 .data
249 .rva func
250 .rva func2
252 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-thunk.s -o test-icf-thunk.obj
253 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-thunk.dll loadcfg.obj test-icf-thunk.obj
254 // RUN: llvm-objdump -d out-icf-thunk.dll | FileCheck --check-prefix=ICF-THUNK %s
256 // ICF-THUNK: Disassembly of section .text:
257 // ICF-THUNK-EMPTY:
258 // ICF-THUNK-NEXT: 0000000180001000 <.text>:
259 // ICF-THUNK-NEXT: 180001000: 00000015 udf #0x15
260 // ICF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
261 // ICF-THUNK-NEXT: 180001008: d65f03c0 ret
262 // ICF-THUNK-NEXT: 18000100c: 00000009 udf #0x9
263 // ICF-THUNK-NEXT: 180001010: 52800040 mov w0, #0x2 // =2
264 // ICF-THUNK-NEXT: 180001014: d65f03c0 ret
265 // ICF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10
266 // ICF-THUNK-NEXT: 18000101c: d65f03c0 ret
268 #--- test-icf-diff-thunk.s
269 // Build two identical functions with different entry thunks and check that they are not merged by ICF.
271 .section .text,"xr",discard,func
272 .globl func
273 .p2align 2
274 func:
275 mov w0, #1
278 .section .text,"xr",discard,func2
279 .globl func2
280 .p2align 2
281 func2:
282 mov w0, #1
285 .section .wowthk$aa,"xr",discard,thunk
286 .globl thunk
287 .p2align 2
288 thunk:
289 mov w0, #10
292 .section .wowthk$aa,"xr",discard,thunk2
293 .globl thunk2
294 .p2align 2
295 thunk2:
296 mov w0, #20
299 .section .hybmp$x, "yi"
300 .symidx func
301 .symidx thunk
302 .word 1 // entry thunk
303 .symidx func2
304 .symidx thunk2
305 .word 1 // entry thunk
307 .data
308 .rva func
309 .rva func2
311 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-diff-thunk.s -o test-icf-diff-thunk.obj
312 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-diff-thunk.dll loadcfg.obj test-icf-diff-thunk.obj
313 // RUN: llvm-objdump -d out-icf-diff-thunk.dll | FileCheck --check-prefix=ICF-DIFF-THUNK %s
315 // ICF-DIFF-THUNK: Disassembly of section .text:
316 // ICF-DIFF-THUNK-EMPTY:
317 // ICF-DIFF-THUNK-NEXT: 0000000180001000 <.text>:
318 // ICF-DIFF-THUNK-NEXT: 180001000: 00000015 udf #0x15
319 // ICF-DIFF-THUNK-NEXT: 180001004: 52800020 mov w0, #0x1 // =1
320 // ICF-DIFF-THUNK-NEXT: 180001008: d65f03c0 ret
321 // ICF-DIFF-THUNK-NEXT: 18000100c: 00000011 udf #0x11
322 // ICF-DIFF-THUNK-NEXT: 180001010: 52800020 mov w0, #0x1 // =1
323 // ICF-DIFF-THUNK-NEXT: 180001014: d65f03c0 ret
324 // ICF-DIFF-THUNK-NEXT: 180001018: 52800140 mov w0, #0xa // =10
325 // ICF-DIFF-THUNK-NEXT: 18000101c: d65f03c0 ret
326 // ICF-DIFF-THUNK-NEXT: 180001020: 52800280 mov w0, #0x14 // =20
327 // ICF-DIFF-THUNK-NEXT: 180001024: d65f03c0 ret
329 #--- test-icf-both.s
330 // Build two identical functions with identical entry thunks and check that they are merged by ICF.
332 .section .text,"xr",discard,func
333 .globl func
334 .p2align 2
335 func:
336 mov w0, #1
339 .section .text,"xr",discard,func2
340 .globl func2
341 .p2align 2
342 func2:
343 mov w0, #1
346 .section .wowthk$aa,"xr",discard,thunk
347 .globl thunk
348 .p2align 2
349 thunk:
350 mov w0, #10
353 .section .wowthk$aa,"xr",discard,thunk2
354 .globl thunk2
355 .p2align 2
356 thunk2:
357 mov w0, #10
360 .section .hybmp$x, "yi"
361 .symidx func
362 .symidx thunk
363 .word 1 // entry thunk
364 .symidx func2
365 .symidx thunk2
366 .word 1 // entry thunk
368 .data
369 .rva func
370 .rva func2
372 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-icf-both.s -o test-icf-both.obj
373 // RUN: lld-link -machine:arm64ec -dll -noentry -out:out-icf-both.dll loadcfg.obj test-icf-both.obj
374 // RUN: llvm-objdump -d out-icf-both.dll | FileCheck --check-prefix=DISASM %s