]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Emit R_LARCH_RELAX for TLS IE with non-extreme code model to allow the...
authorXi Ruoyao <xry111@xry111.site>
Fri, 26 Jan 2024 10:28:32 +0000 (18:28 +0800)
committerXi Ruoyao <xry111@xry111.site>
Sat, 9 Mar 2024 09:50:00 +0000 (17:50 +0800)
commit42cd49aa48c7ca99e8d5e91ce582d41fdb75f3fc
treeb158b847f7af2dac9249bf145744759f26b932fc
parente8cc1f956b75a6bf74c5f5262ddced9451dcccac
LoongArch: Emit R_LARCH_RELAX for TLS IE with non-extreme code model to allow the IE to LE linker relaxation

In Binutils we need to make IE to LE relaxation only allowed when there
is an R_LARCH_RELAX after R_LARCH_TLE_IE_PC_{HI20,LO12} so an invalid
"partial" relaxation won't happen with the extreme code model.  So if we
are emitting %ie_pc_{hi20,lo12} in a non-extreme code model, emit an
R_LARCH_RELAX to allow the relaxation.  The IE to LE relaxation does not
require the pcalau12i and the ld instruction to be adjacent, so we don't
need to limit ourselves to use the macro.

For the distro maintainers backporting changes: this change depends on
r14-8721, without r14-8721 R_LARCH_RELAX can be emitted mistakenly in
the extreme code model.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_print_operand_reloc):
Support 'Q' for R_LARCH_RELAX for TLS IE.
(loongarch_output_move): Use 'Q' to print R_LARCH_RELAX for TLS
IE.
* config/loongarch/loongarch.md (ld_from_got<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/tls-ie-relax.c: New test.
* gcc.target/loongarch/tls-ie-norelax.c: New test.
* gcc.target/loongarch/tls-ie-extreme.c: New test.
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/tls-ie-extreme.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/tls-ie-norelax.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/tls-ie-relax.c [new file with mode: 0644]