Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / arm64-thunk-for-alignment.s
blobf497b81f705b2d364704bbb8206ab07aacbe7464
1 # REQUIRES: aarch64
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o
4 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o
5 # RUN: %lld -dylib -arch arm64 -lSystem -o %t/out %t/foo.o %t/bar.o
7 # RUN: llvm-objdump --macho --syms %t/out | FileCheck %s
8 # CHECK: _bar.thunk.0
10 ## Regression test for PR59259. Previously, we neglected to check section
11 ## alignments when deciding when to create thunks.
13 ## If we ignore alignment, the total size of _spacer1 + _spacer2 below is just
14 ## under the limit at which we attempt to insert thunks between the spacers.
15 ## However, with alignment accounted for, their total size ends up being
16 ## 0x8000000, which is just above the max forward branch range, making thunk
17 ## insertion necessary. Thus, not accounting for alignment led to an error.
19 #--- foo.s
21 _foo:
22 b _bar
24 ## Size of a `b` instruction.
25 .equ callSize, 4
26 ## Refer to `slop` in TextOutputSection::finalize().
27 .equ slopSize, 12 * 256
29 _spacer1:
30 .space 0x4000000 - slopSize - 2 * callSize - 1
32 .subsections_via_symbols
34 #--- bar.s
35 .globl _bar
37 .p2align 14
38 _spacer2:
39 .space 0x4000000
41 _bar:
42 ret
44 .subsections_via_symbols