Skip to content

Commit 74b9415

Browse files
committed
fixes for reviews.
1 parent 3a3dd03 commit 74b9415

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

lld/test/ELF/loongarch-relax-pc-hi20-lo12.s

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# REQUIRES: loongarch
2+
# RUN: rm -rf %t && split-file %s %t && cd %t
23

3-
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax --defsym ELF32=1 %s -o %t.32.o
4-
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax %s -o %t.64.o
4+
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax a.s -o a.32.o
5+
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax a.s -o a.64.o
56

6-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t.32.o -o %t.32
7-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t.64.o -o %t.64
8-
# RUN: llvm-objdump -td --no-show-raw-insn %t.32 | FileCheck --check-prefixes=RELAX,RELAX32 %s
9-
# RUN: llvm-objdump -td --no-show-raw-insn %t.64 | FileCheck --check-prefixes=RELAX,RELAX64 %s
7+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a.32.o -o a.32
8+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a.64.o -o a.64
9+
# RUN: llvm-objdump -td --no-show-raw-insn a.32 | FileCheck --check-prefixes=RELAX %s
10+
# RUN: llvm-objdump -td --no-show-raw-insn a.64 | FileCheck --check-prefixes=RELAX %s
1011

11-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t.32.o -shared -o %t.32s
12-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t.64.o -shared -o %t.64s
13-
# RUN: llvm-objdump -td --no-show-raw-insn %t.32s | FileCheck --check-prefixes=RELAX %s
14-
# RUN: llvm-objdump -td --no-show-raw-insn %t.64s | FileCheck --check-prefixes=RELAX %s
12+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a.32.o -shared -o a.32s
13+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a.64.o -shared -o a.64s
14+
# RUN: llvm-objdump -td --no-show-raw-insn a.32s | FileCheck --check-prefixes=RELAX %s
15+
# RUN: llvm-objdump -td --no-show-raw-insn a.64s | FileCheck --check-prefixes=RELAX %s
1516

16-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 %t.32.o -o %t.32o
17-
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 %t.64.o -o %t.64o
18-
# RUN: llvm-objdump -td --no-show-raw-insn %t.32o | FileCheck --check-prefixes=NORELAX32 %s
19-
# RUN: llvm-objdump -td --no-show-raw-insn %t.64o | FileCheck --check-prefixes=NORELAX64 %s
17+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 a.32.o -o a.32o
18+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 a.64.o -o a.64o
19+
# RUN: llvm-objdump -td --no-show-raw-insn a.32o | FileCheck --check-prefixes=NORELAX32 %s
20+
# RUN: llvm-objdump -td --no-show-raw-insn a.64o | FileCheck --check-prefixes=NORELAX64 %s
2021

2122
# RELAX-LABEL: <_start>:
2223
## offset = 0x14000 - 0x10000 = 4096<<2
@@ -25,11 +26,6 @@
2526
# RELAX-NEXT: pcaddi $a0, 4094
2627
# RELAX-NEXT: pcaddi $a0, 4093
2728

28-
# RELAX32-NEXT: pcalau12i $a0, 4
29-
# RELAX32-NEXT: ld.w $a0, $a0, 8
30-
# RELAX64-NEXT: pcalau12i $a0, 4
31-
# RELAX64-NEXT: ld.d $a0, $a0, 12
32-
3329
# NORELAX32-LABEL: <_start>:
3430
## offset exceed range of pcaddi
3531
## offset = 0x410000 - 0x10000: 0x400 pages, page offset 0
@@ -41,8 +37,6 @@
4137
# NORELAX32-NEXT: addi.w $a0, $a0, 0
4238
# NORELAX32-NEXT: pcalau12i $a0, 1024
4339
# NORELAX32-NEXT: ld.w $a0, $a0, 4
44-
# NORELAX32-NEXT: pcalau12i $a0, 1024
45-
# NORELAX32-NEXT: ld.w $a0, $a0, 8
4640

4741
# NORELAX64-LABEL: <_start>:
4842
## offset exceed range of pcaddi
@@ -55,17 +49,26 @@
5549
# NORELAX64-NEXT: addi.d $a0, $a0, 0
5650
# NORELAX64-NEXT: pcalau12i $a0, 1024
5751
# NORELAX64-NEXT: ld.d $a0, $a0, 8
58-
# NORELAX64-NEXT: pcalau12i $a0, 1024
59-
# NORELAX64-NEXT: ld.d $a0, $a0, 12
6052

61-
.macro ld dst, src1, src2
62-
.ifdef ELF32
63-
ld.w \dst, \src1, \src2
64-
.else
65-
ld.d \dst, \src1, \src2
66-
.endif
67-
.endm
6853

54+
## GOT references with non-zero addends. No relaxation.
55+
# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax nonzero.s -o nonzero.32.o
56+
# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax nonzero.s -o nonzero.64.o
57+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.32.o -o nonzero.32
58+
# RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.64.o -o nonzero.64
59+
# RUN: llvm-objdump -td --no-show-raw-insn nonzero.32 | FileCheck --check-prefixes=NONZERO32 %s
60+
# RUN: llvm-objdump -td --no-show-raw-insn nonzero.64 | FileCheck --check-prefixes=NONZERO64 %s
61+
62+
# NONZERO32-LABEL: <_start>:
63+
# NONZERO32-NEXT: 10000: pcalau12i $a0, 4
64+
# NONZERO32-NEXT: ld.w $a0, $a0, 8
65+
66+
# NONZERO64-LABEL: <_start>:
67+
# NONZERO64-NEXT: 10000: pcalau12i $a0, 4
68+
# NONZERO64-NEXT: ld.d $a0, $a0, 12
69+
70+
71+
#--- a.s
6972
.section .text
7073
.global _start
7174
_start:
@@ -74,10 +77,16 @@ _start:
7477
la.pcrel $a0, sym
7578
la.got $a0, sym
7679

77-
pcalau12i $a0, %got_pc_hi20(sym+4)
78-
.reloc .-4, R_LARCH_RELAX, 0
79-
ld $a0, $a0, %got_pc_lo12(sym+4)
80-
.reloc .-4, R_LARCH_RELAX, 0
80+
.section .data
81+
sym:
82+
.zero 4
83+
84+
85+
#--- nonzero.s
86+
.section .text
87+
.global _start
88+
_start:
89+
la.got $a0, sym+4
8190

8291
.section .data
8392
sym:

0 commit comments

Comments
 (0)