Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / arm64-thunk-visibility.s
blob5fa195f8b115651f348bd6e39748f1520ec2f587
1 # REQUIRES: aarch64
3 # foo.s and bar.s both contain TU-local symbols (think static function)
4 # with the same name, and both need a thunk. This tests that ld64.lld doesn't
5 # create a duplicate symbol for the two functions.
7 # Test this both when the TU-local symbol is the branch source or target,
8 # and for both forward and backwards jumps.
10 # RUN: rm -rf %t; split-file %s %t
11 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o
12 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o
13 # RUN: %lld -arch arm64 -lSystem -o %t.out %t/foo.o %t/bar.o
15 #--- foo.s
17 .subsections_via_symbols
19 # Note: No .globl, since these are TU-local symbols.
20 .p2align 2
21 _early_jumping_local_fn: b _some_late_external
22 .p2align 2
23 _early_landing_local_fn: ret
25 .globl _some_early_external
26 .p2align 2
27 _some_early_external: b _late_landing_local_fn
29 ## 0x8000000 is 128 MiB, one more than the forward branch limit.
30 ## Distribute that over two functions since our thunk insertion algorithm
31 ## can't deal with a single function that's 128 MiB.
32 .global _spacer1, _spacer2
33 _spacer1:
34 .space 0x4000000
35 _spacer2:
36 .space 0x4000000
38 # Note: No .globl, since these are TU-local symbols.
39 .p2align 2
40 _late_jumping_local_fn: b _some_early_external
41 .p2align 2
42 _late_landing_local_fn: ret
44 .globl _some_late_external
45 .p2align 2
46 _some_late_external: b _early_landing_local_fn
48 #--- bar.s
50 .subsections_via_symbols
52 # Note: No .globl, since these are TU-local symbols.
53 .p2align 2
54 _early_jumping_local_fn: b _some_other_late_external
55 .p2align 2
56 _early_landing_local_fn: ret
58 .globl _some_other_early_external
59 .p2align 2
60 _some_other_early_external: b _late_landing_local_fn
62 ## 0x8000000 is 128 MiB, one more than the forward branch limit.
63 ## Distribute that over two functions since our thunk insertion algorithm
64 ## can't deal with a single function that's 128 MiB.
65 .global _other_spacer1, _other_spacer1
66 _spacer1:
67 .space 0x4000000
68 _spacer2:
69 .space 0x4000000
71 # Note: No .globl, since these are TU-local symbols.
72 .p2align 2
73 _late_jumping_local_fn: b _some_other_early_external
74 .p2align 2
75 _late_landing_local_fn: ret
77 .globl _some_other_late_external
78 .p2align 2
79 _some_other_late_external: b _early_landing_local_fn
81 .globl _main
82 _main:
83 ret