2018-05-04 23:09:49 +08:00
|
|
|
# REQUIRES: ppc
|
|
|
|
|
[PPC64] toc-indirect to toc-relative relaxation
This is based on D54720 by Sean Fertile.
When accessing a global symbol which is not defined in the translation unit,
compilers will generate instructions that load the address from the toc entry.
If the symbol is defined, non-preemptable, and addressable with a 32-bit
signed offset from the toc pointer, the address can be computed
directly. e.g.
addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry
ld/lwa 3, 0(3) # load the value from the address
.section .toc,"aw",@progbits
.LC0: .tc var[TC],var
can be relaxed to
addis 3,2,var@toc@ha # this may be relaxed to a nop,
addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc
ld/lwa 3, 0(3) # load the value from the address
We can delete the test ppc64-got-indirect.s as its purpose is covered by
newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s
Reviewed By: ruiu, sfertile
Differential Revision: https://reviews.llvm.org/D60958
llvm-svn: 360112
2019-05-07 12:26:05 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
|
|
|
|
# RUN: ld.lld --no-toc-optimize %t.o -o %t
|
2019-06-03 14:21:33 +08:00
|
|
|
# RUN: llvm-readelf -x .rodata -x .R_PPC64_TOC -x .eh_frame %t | FileCheck %s --check-prefix=DATALE
|
[PPC64] toc-indirect to toc-relative relaxation
This is based on D54720 by Sean Fertile.
When accessing a global symbol which is not defined in the translation unit,
compilers will generate instructions that load the address from the toc entry.
If the symbol is defined, non-preemptable, and addressable with a 32-bit
signed offset from the toc pointer, the address can be computed
directly. e.g.
addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry
ld/lwa 3, 0(3) # load the value from the address
.section .toc,"aw",@progbits
.LC0: .tc var[TC],var
can be relaxed to
addis 3,2,var@toc@ha # this may be relaxed to a nop,
addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc
ld/lwa 3, 0(3) # load the value from the address
We can delete the test ppc64-got-indirect.s as its purpose is covered by
newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s
Reviewed By: ruiu, sfertile
Differential Revision: https://reviews.llvm.org/D60958
llvm-svn: 360112
2019-05-07 12:26:05 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
|
2018-05-04 23:09:49 +08:00
|
|
|
|
[PPC64] toc-indirect to toc-relative relaxation
This is based on D54720 by Sean Fertile.
When accessing a global symbol which is not defined in the translation unit,
compilers will generate instructions that load the address from the toc entry.
If the symbol is defined, non-preemptable, and addressable with a 32-bit
signed offset from the toc pointer, the address can be computed
directly. e.g.
addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry
ld/lwa 3, 0(3) # load the value from the address
.section .toc,"aw",@progbits
.LC0: .tc var[TC],var
can be relaxed to
addis 3,2,var@toc@ha # this may be relaxed to a nop,
addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc
ld/lwa 3, 0(3) # load the value from the address
We can delete the test ppc64-got-indirect.s as its purpose is covered by
newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s
Reviewed By: ruiu, sfertile
Differential Revision: https://reviews.llvm.org/D60958
llvm-svn: 360112
2019-05-07 12:26:05 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
|
|
|
|
# RUN: ld.lld --no-toc-optimize %t.o -o %t
|
2019-06-03 14:21:33 +08:00
|
|
|
# RUN: llvm-readelf -x .rodata -x .R_PPC64_TOC -x .eh_frame %t | FileCheck %s --check-prefix=DATABE
|
[PPC64] toc-indirect to toc-relative relaxation
This is based on D54720 by Sean Fertile.
When accessing a global symbol which is not defined in the translation unit,
compilers will generate instructions that load the address from the toc entry.
If the symbol is defined, non-preemptable, and addressable with a 32-bit
signed offset from the toc pointer, the address can be computed
directly. e.g.
addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry
ld/lwa 3, 0(3) # load the value from the address
.section .toc,"aw",@progbits
.LC0: .tc var[TC],var
can be relaxed to
addis 3,2,var@toc@ha # this may be relaxed to a nop,
addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc
ld/lwa 3, 0(3) # load the value from the address
We can delete the test ppc64-got-indirect.s as its purpose is covered by
newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s
Reviewed By: ruiu, sfertile
Differential Revision: https://reviews.llvm.org/D60958
llvm-svn: 360112
2019-05-07 12:26:05 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
|
2015-10-13 04:56:18 +08:00
|
|
|
|
2018-05-04 23:09:49 +08:00
|
|
|
.text
|
2015-10-13 04:56:18 +08:00
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
.Lfoo:
|
|
|
|
li 0,1
|
|
|
|
li 3,42
|
|
|
|
sc
|
|
|
|
|
2019-08-17 14:28:03 +08:00
|
|
|
.section .toc,"aw",@progbits
|
2015-10-13 04:56:18 +08:00
|
|
|
.L1:
|
2019-08-17 14:28:03 +08:00
|
|
|
.quad 22, 37, 89, 47
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_TOC16_LO_DS,"ax",@progbits
|
|
|
|
ld 1, .L1@toc@l(2)
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_LO_DS:
|
2019-04-23 19:47:28 +08:00
|
|
|
# CHECK: 1001000c: ld 1, -32768(2)
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_TOC16_LO,"ax",@progbits
|
|
|
|
addi 1, 2, .L1@toc@l
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_LO:
|
2019-04-23 19:47:28 +08:00
|
|
|
# CHECK: 10010010: addi 1, 2, -32768
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_TOC16_HI,"ax",@progbits
|
|
|
|
addis 1, 2, .L1@toc@h
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HI:
|
2019-04-23 19:47:28 +08:00
|
|
|
# CHECK: 10010014: addis 1, 2, -1
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_TOC16_HA,"ax",@progbits
|
|
|
|
addis 1, 2, .L1@toc@ha
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HA:
|
[PPC64] toc-indirect to toc-relative relaxation
This is based on D54720 by Sean Fertile.
When accessing a global symbol which is not defined in the translation unit,
compilers will generate instructions that load the address from the toc entry.
If the symbol is defined, non-preemptable, and addressable with a 32-bit
signed offset from the toc pointer, the address can be computed
directly. e.g.
addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA
ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry
ld/lwa 3, 0(3) # load the value from the address
.section .toc,"aw",@progbits
.LC0: .tc var[TC],var
can be relaxed to
addis 3,2,var@toc@ha # this may be relaxed to a nop,
addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc
ld/lwa 3, 0(3) # load the value from the address
We can delete the test ppc64-got-indirect.s as its purpose is covered by
newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s
Reviewed By: ruiu, sfertile
Differential Revision: https://reviews.llvm.org/D60958
llvm-svn: 360112
2019-05-07 12:26:05 +08:00
|
|
|
# CHECK: 10010018: addis 1, 2, 0
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_LO,"ax",@progbits
|
|
|
|
li 1, .Lfoo@l
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_LO:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 0
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HI,"ax",@progbits
|
|
|
|
li 1, .Lfoo@h
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HI:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 4097
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HA,"ax",@progbits
|
|
|
|
li 1, .Lfoo@ha
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HA:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 4097
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HIGHER,"ax",@progbits
|
|
|
|
li 1, .Lfoo@higher
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHER:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 0
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits
|
|
|
|
li 1, .Lfoo@highera
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHERA:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 0
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits
|
|
|
|
li 1, .Lfoo@highest
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHEST:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 0
|
2015-10-13 04:56:18 +08:00
|
|
|
|
|
|
|
.section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits
|
|
|
|
li 1, .Lfoo@highesta
|
|
|
|
|
2019-05-31 23:41:19 +08:00
|
|
|
# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHESTA:
|
2019-08-17 14:28:03 +08:00
|
|
|
# CHECK: li 1, 0
|
2018-05-15 00:39:45 +08:00
|
|
|
|
2019-06-03 14:21:33 +08:00
|
|
|
.section .R_PPC64_TOC,"a",@progbits
|
|
|
|
.quad .TOC.@tocbase
|
|
|
|
|
|
|
|
# SEC: .got PROGBITS 0000000010020000
|
|
|
|
|
|
|
|
## tocbase = .got+0x8000 = 0x10028000
|
|
|
|
# DATALE-LABEL: section '.R_PPC64_TOC':
|
|
|
|
# DATALE: 00800210 00000000
|
|
|
|
|
|
|
|
# DATABE-LABEL: section '.R_PPC64_TOC':
|
|
|
|
# DATABE: 00000000 10028000
|