|
1 | | -## Check that llvm-bolt correctly recognizes long absolute thunks generated |
2 | | -## by LLD. |
| 1 | +## Check that llvm-bolt correctly recognizes veneers/thunks for absolute code |
| 2 | +## generated by LLD. |
3 | 3 |
|
4 | 4 | # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o |
5 | 5 | # RUN: %clang %cflags -fno-PIC -no-pie %t.o -o %t.exe -nostdlib \ |
|
12 | 12 |
|
13 | 13 | .text |
14 | 14 | .balign 4 |
15 | | -.global foo |
16 | | -.type foo, %function |
17 | | -foo: |
18 | | - adrp x1, foo |
| 15 | +.global far_function |
| 16 | +.type far_function, %function |
| 17 | +far_function: |
19 | 18 | ret |
20 | | -.size foo, .-foo |
| 19 | +.size far_function, .-far_function |
| 20 | + |
| 21 | +.global near_function |
| 22 | +.type near_function, %function |
| 23 | +near_function: |
| 24 | + ret |
| 25 | +.size near_function, .-near_function |
21 | 26 |
|
22 | 27 | .section ".mytext", "ax" |
23 | 28 | .balign 4 |
24 | 29 |
|
25 | | -.global __AArch64AbsLongThunk_foo |
26 | | -.type __AArch64AbsLongThunk_foo, %function |
27 | | -__AArch64AbsLongThunk_foo: |
| 30 | +## This version of a thunk is always generated by LLD for function calls |
| 31 | +## spanning more than 256MB. |
| 32 | +.global __AArch64AbsLongThunk_far_function |
| 33 | +.type __AArch64AbsLongThunk_far_function, %function |
| 34 | +__AArch64AbsLongThunk_far_function: |
28 | 35 | ldr x16, .L1 |
29 | 36 | br x16 |
30 | | -# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_foo>: |
| 37 | +# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_far_function>: |
31 | 38 | # CHECK-INPUT-NEXT: ldr |
32 | 39 | # CHECK-INPUT-NEXT: br |
33 | 40 | .L1: |
34 | | - .quad foo |
35 | | -.size __AArch64AbsLongThunk_foo, .-__AArch64AbsLongThunk_foo |
| 41 | + .quad far_function |
| 42 | +.size __AArch64AbsLongThunk_far_function, .-__AArch64AbsLongThunk_far_function |
| 43 | + |
| 44 | +## If a callee is closer than 256MB away, LLD may generate a thunk with a direct |
| 45 | +## jump to the callee. Note, that the name might still include "AbSLong". |
| 46 | +.global __AArch64AbsLongThunk_near_function |
| 47 | +.type __AArch64AbsLongThunk_near_function, %function |
| 48 | +__AArch64AbsLongThunk_near_function: |
| 49 | + b near_function |
| 50 | +# CHECK-INPUT-LABEL: <__AArch64AbsLongThunk_near_function>: |
| 51 | +# CHECK-INPUT-NEXT: b {{.*}} <near_function> |
| 52 | +.size __AArch64AbsLongThunk_near_function, .-__AArch64AbsLongThunk_near_function |
36 | 53 |
|
37 | | -## Check that the thunk was removed from .text and _start() calls foo() |
| 54 | +## Check that thunks were removed from .text, and _start calls functions |
38 | 55 | ## directly. |
39 | 56 |
|
40 | | -# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_foo |
| 57 | +# CHECK-OUTPUT-NOT: __AArch64AbsLongThunk_{{.*}} |
41 | 58 |
|
42 | 59 | .global _start |
43 | 60 | .type _start, %function |
44 | 61 | _start: |
45 | 62 | # CHECK-INPUT-LABEL: <_start>: |
46 | 63 | # CHECK-OUTPUT-LABEL: <_start>: |
47 | | - bl __AArch64AbsLongThunk_foo |
48 | | -# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_foo> |
49 | | -# CHECK-OUTPUT-NEXT: bl {{.*}} <foo> |
| 64 | + bl __AArch64AbsLongThunk_far_function |
| 65 | + bl __AArch64AbsLongThunk_near_function |
| 66 | +# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_far_function> |
| 67 | +# CHECK-INPUT-NEXT: bl {{.*}} <__AArch64AbsLongThunk_near_function> |
| 68 | +# CHECK-OUTPUT-NEXT: bl {{.*}} <far_function> |
| 69 | +# CHECK-OUTPUT-NEXT: bl {{.*}} <near_function> |
50 | 70 | ret |
51 | 71 | .size _start, .-_start |
0 commit comments