[PATCH v2 0/2] LoongArch: TLS type transition instruction removal and old LE rela
Lulu Cai
cailulu@loongson.cn
Sun Feb 4 03:11:30 GMT 2024
More information about the Binutils mailing list
Sun Feb 4 03:11:30 GMT 2024
- Previous message (by thread): [PATCH] Fix disabling of year 2038 support on 32-bit hosts by default
- Next message (by thread): [PATCH v2 1/2] LoongArch: Delete extra instructions when TLS type transition
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This modification mainly changes the timing of type transition,
adds relaxation to the old LE instruction sequence.
We strictly distinguish between type transition and relaxation.
Type transition is from one type to another, while relaxation
is the removal of instructions under the same TLS type. Detailed
instructions are as follows:
1. For type transition, only the normal code model of DESC/IE
does type transition, and each relocation is accompanied by a
R_LARCH_RELAX. Neither abs nor extreme will do type transition,
and no R_LARCH_RELAX will be generated.
The extra instructions when DESC transitions to other TLS types
will be deleted during the type transition.
Type Transition Delete Instructions:
pcalau12i $a0,%desc_pc_hi20(sym) => pcalau12i $a0,%ie_pc_hi20(sym)
addi.d $a0,$a0,%desc_pc_lo12(sym) => ld.d $a0,$a0,%ie_pc_lo12(sym)
ld.d $ra,$a0,%desc_ld(sym) => (deleted)
jirl $ra,$ra,%desc_call(sym) => (deleted)
2. Implemented relaxation for the old LE instruction sequence.
The first two instructions of LE's 32-bit and 64-bit models
use the same relocations and cannot be distinguished based on
relocations. Therefore, for LE's instruction sequence, any code
model will try to relaxation.
LE of 32-bit relaxation:
lu12i.w $a0,%le_hi20(sym) => (deleted)
ori $a0,$a0,%le_lo12(sym) => ori $a0,$zero,%le_lo12(sym)
LE of 64-bit relaxation:
lu12i.w $a0,$le_hi20(sym) => (deleted)
ori $a0,%le_lo12(sym) => ori $a0,$zero,%le_lo12(sym)
lu32i.d $a0,%le64_lo20(sym) => (deleted)
lu52i.d $a0,$a0,le64_hi12(sym) => (deleted)
3. Some function names have been adjusted to facilitate understanding,
parameters have been adjusted, and unused macros have been deleted.
----
V1 -> V2:
* Distinguished the different behavior of type transitions when using
--relax/--no-relax.
If --no-relax is used, the nop in DESC->IE/LE will not be deleted.
such as DESC->LE:
pcalau12i $a0,%desc_pc_hi20(sym) => lu12i.w $a0,%le_hi20(sym)
addi.d $a0,$a0,%desc_pc_lo12(sym) => ori $a0,$a0,%le_lo12(sym)
ld.d $ra,$a0,%desc_ld(sym) => nop
jirl $ra,$ra,%desc_call(sym) => nop
If --relax is used, the nop in DESC->IE/LE will be deleted. And it
will try to relaxation the LE instruction sequence after the tls type
transition.
* Added a check to see if the current relocation is the last for the
section to prevent excessive reads.
* Added new test cases for testing --relax and --no-relax.
Lulu Cai (2):
LoongArch: Delete extra instructions when TLS type transition
LoongArch: Fix some test cases for TLS transition and relax
bfd/elfnn-loongarch.c | 420 +++++++++++-------
gas/config/tc-loongarch.c | 31 +-
gas/testsuite/gas/loongarch/macro_op.d | 4 +
gas/testsuite/gas/loongarch/macro_op_32.d | 4 +
.../gas/loongarch/macro_op_extreme_abs.d | 4 +-
.../gas/loongarch/macro_op_extreme_pc.d | 2 +
.../relax-cfi-fde-DW_CFA_advance_loc.d | 16 +-
.../relax-cfi-fde-DW_CFA_advance_loc.s | 8 +
gas/testsuite/gas/loongarch/reloc.d | 8 +
gas/testsuite/gas/loongarch/tlsdesc_32.d | 2 +
gas/testsuite/gas/loongarch/tlsdesc_64.d | 2 +
ld/testsuite/ld-loongarch-elf/desc-ie.d | 14 +-
ld/testsuite/ld-loongarch-elf/desc-ie.s | 13 +-
.../ld-loongarch-elf/desc-le-norelax.d | 15 +
.../ld-loongarch-elf/desc-le-norelax.s | 11 +
ld/testsuite/ld-loongarch-elf/desc-le-relax.d | 13 +
ld/testsuite/ld-loongarch-elf/desc-le-relax.s | 14 +
ld/testsuite/ld-loongarch-elf/desc-le.d | 15 -
ld/testsuite/ld-loongarch-elf/desc-le.s | 14 -
ld/testsuite/ld-loongarch-elf/ie-le-norelax.d | 13 +
.../{ie-le.s => ie-le-norelax.s} | 4 +-
ld/testsuite/ld-loongarch-elf/ie-le-relax.d | 13 +
ld/testsuite/ld-loongarch-elf/ie-le-relax.s | 13 +
ld/testsuite/ld-loongarch-elf/ie-le.d | 13 -
.../ld-loongarch-elf/ld-loongarch-elf.exp | 9 +-
ld/testsuite/ld-loongarch-elf/macro_op.d | 4 +
ld/testsuite/ld-loongarch-elf/macro_op_32.d | 4 +
ld/testsuite/ld-loongarch-elf/relax.exp | 6 +-
.../ld-loongarch-elf/tls-le-norelax.d | 18 +
.../{tls-le.s => tls-le-norelax.s} | 4 +
ld/testsuite/ld-loongarch-elf/tls-le-relax.d | 13 +
ld/testsuite/ld-loongarch-elf/tls-le-relax.s | 22 +
ld/testsuite/ld-loongarch-elf/tls-le.d | 14 -
ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d | 84 ++--
34 files changed, 540 insertions(+), 304 deletions(-)
create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le-norelax.d
create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le-norelax.s
create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le-relax.d
create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le-relax.s
delete mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.d
delete mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.s
create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le-norelax.d
rename ld/testsuite/ld-loongarch-elf/{ie-le.s => ie-le-norelax.s} (63%)
create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le-relax.d
create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le-relax.s
delete mode 100644 ld/testsuite/ld-loongarch-elf/ie-le.d
create mode 100644 ld/testsuite/ld-loongarch-elf/tls-le-norelax.d
rename ld/testsuite/ld-loongarch-elf/{tls-le.s => tls-le-norelax.s} (70%)
create mode 100644 ld/testsuite/ld-loongarch-elf/tls-le-relax.d
create mode 100644 ld/testsuite/ld-loongarch-elf/tls-le-relax.s
delete mode 100644 ld/testsuite/ld-loongarch-elf/tls-le.d
--
2.36.0
- Previous message (by thread): [PATCH] Fix disabling of year 2038 support on 32-bit hosts by default
- Next message (by thread): [PATCH v2 1/2] LoongArch: Delete extra instructions when TLS type transition
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list