2 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
5 # RUN: ld.lld %t/a.o -T %t/out-of-adr-range-low.t -o %t/a-low
6 # RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=OUT-OF-RANGE
7 # RUN: ld.lld %t/a.o -T %t/out-of-adr-range-high.t -o %t/a-high
8 # RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=OUT-OF-RANGE
10 # OUT-OF-RANGE: adrp x30
11 # OUT-OF-RANGE-NEXT: add x30, x30
13 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
14 # RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t -o %t/a-low
15 # RUN: llvm-objdump --no-show-raw-insn -d %t/a-low | FileCheck %s --check-prefix=IN-RANGE-LOW
18 # IN-RANGE-LOW-NEXT: adr x30
19 # IN-RANGE-LOW-NEXT: adrp x1
20 # IN-RANGE-LOW-NEXT: add x1
21 # IN-RANGE-LOW-NEXT: adrp x15
22 # IN-RANGE-LOW-NEXT: add x15
24 ## ADRP and ADD use different registers, no relaxations should be applied.
25 # IN-RANGE-LOW-NEXT: adrp x2
26 # IN-RANGE-LOW-NEXT: add x3, x2
28 ## ADRP and ADD use different registers, no relaxations should be applied.
29 # IN-RANGE-LOW-NEXT: adrp x2
30 # IN-RANGE-LOW-NEXT: add x2, x3
32 # RUN: ld.lld %t/a.o -T %t/within-adr-range-high.t -o %t/a-high
33 # RUN: llvm-objdump --no-show-raw-insn -d %t/a-high | FileCheck %s --check-prefix=IN-RANGE-HIGH
36 # IN-RANGE-HIGH-NEXT: adr x30
37 # IN-RANGE-HIGH-NEXT: nop
38 # IN-RANGE-HIGH-NEXT: adr x1
39 # IN-RANGE-HIGH-NEXT: nop
40 # IN-RANGE-HIGH-NEXT: adr x15
42 ## ADRP and ADD use different registers, no relaxations should be applied.
43 # IN-RANGE-HIGH-NEXT: adrp x2
44 # IN-RANGE-HIGH-NEXT: add x3, x2
46 ## ADRP and ADD use different registers, no relaxations should be applied.
47 # IN-RANGE-HIGH-NEXT: adrp x2
48 # IN-RANGE-HIGH-NEXT: add x2, x3
50 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
51 # RUN: ld.lld %t/a.o -T %t/within-adr-range-low.t --no-relax -o %t/a
52 ## --no-relax disables relaxations.
53 # RUN: llvm-objdump --no-show-raw-insn -d %t/a | FileCheck %s --check-prefix=OUT-OF-RANGE
55 ## .rodata and .text are close to each other,
56 ## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference
57 ## is equal to the lowest allowed value.
58 #--- within-adr-range-low.t
60 .rodata 0x1000: { *(.rodata) }
61 .text 0x100ffc: { *(.text) }
64 ## .rodata and .text are far apart,
65 ## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference
66 ## is equal to the lowest allowed value minus one.
67 #--- out-of-adr-range-low.t
69 .rodata 0x1000: { *(.rodata) }
70 .text 0x100ffd: { *(.text) }
73 ## .rodata and .text are close to each other,
74 ## the adrp + add pair can be relaxed to nop + adr, moreover, the address difference
75 ## is equal to the highest allowed value.
76 #--- within-adr-range-high.t
78 .text 0x1000: { *(.text) }
79 .rodata 0x101003: { *(.rodata) }
82 ## .rodata and .text are far apart,
83 ## the adrp + add pair cannot be relaxed to nop + adr, moreover, the address difference
84 ## is equal to the highest allowed value plus one.
85 #--- out-of-adr-range-high.t
87 .text 0x1000: { *(.text) }
88 .rodata 0x101004: { *(.rodata) }
103 add x15
, x15
, :lo12
:x