[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / aarch64-adrp-add.s
blob3b3eb18f04cb5658d5078860a4119ae2946f360b
1 # REQUIRES: aarch64
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
17 # IN-RANGE-LOW: nop
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
35 # IN-RANGE-HIGH: nop
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
59 SECTIONS {
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
68 SECTIONS {
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
77 SECTIONS {
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
86 SECTIONS {
87 .text 0x1000: { *(.text) }
88 .rodata 0x101004: { *(.rodata) }
91 #--- a.s
92 .rodata
94 .word 10
95 .text
96 .global _start
97 _start:
98 adrp x30, x
99 add x30, x30, :lo12:x
100 adrp x1, x
101 add x1, x1, :lo12:x
102 adrp x15, x
103 add x15, x15, :lo12:x
104 adrp x2, x
105 add x3, x2, :lo12:x
106 adrp x2, x
107 add x2, x3, :lo12:x