Projects
openEuler:24.03:SP1:Everything
gcc
_service:tar_scm:0126-LoongArch-Enable-explicit...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0126-LoongArch-Enable-explicit-reloc-for-extreme-TLS-GD-L.patch of Package gcc
From 1ccf16353b2be4308c79f3b011cb800bfa6f94f4 Mon Sep 17 00:00:00 2001 From: Lulu Cheng <chenglulu@loongson.cn> Date: Fri, 26 Jan 2024 10:46:51 +0800 Subject: [PATCH 126/188] LoongArch: Enable explicit reloc for extreme TLS GD/LD with -mexplicit-relocs=auto. Binutils does not support relaxation using four instructions to obtain symbol addresses gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_explicit_relocs_p): When the code model of the symbol is extreme and -mexplicit-relocs=auto, the macro instruction loading symbol address is not applicable. (loongarch_call_tls_get_addr): Adjust code. (loongarch_legitimize_tls_address): Likewise. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-extreme-auto-tls-ld-gd.c: New test. * gcc.target/loongarch/explicit-relocs-medium-auto-tls-ld-gd.c: New test. --- gcc/config/loongarch/loongarch.cc | 19 +++++++++---------- .../explicit-relocs-extreme-auto-tls-ld-gd.c | 5 +++++ .../explicit-relocs-medium-auto-tls-ld-gd.c | 5 +++++ 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-auto-tls-ld-gd.c create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-auto-tls-ld-gd.c diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 9cfe5bfb2..84b949021 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -1968,6 +1968,10 @@ loongarch_explicit_relocs_p (enum loongarch_symbol_type type) if (la_opt_explicit_relocs != EXPLICIT_RELOCS_AUTO) return la_opt_explicit_relocs == EXPLICIT_RELOCS_ALWAYS; + /* The linker don't know how to relax accesses in extreme code model. */ + if (loongarch_symbol_extreme_p (type)) + return true; + switch (type) { case SYMBOL_TLS_IE: @@ -1979,11 +1983,6 @@ loongarch_explicit_relocs_p (enum loongarch_symbol_type type) does not relax 64-bit pc-relative accesses as at now. */ return true; case SYMBOL_GOT_DISP: - /* The linker don't know how to relax GOT accesses in extreme - code model. */ - if (TARGET_CMODEL_EXTREME) - return true; - /* If we are performing LTO for a final link, and we have the linker plugin so we know the resolution of the symbols, then all GOT references are binding to external symbols or @@ -2772,7 +2771,7 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0) start_sequence (); - if (la_opt_explicit_relocs == EXPLICIT_RELOCS_ALWAYS) + if (loongarch_explicit_relocs_p (type)) { /* Split tls symbol to high and low. */ rtx high = gen_rtx_HIGH (Pmode, copy_rtx (loc)); @@ -2805,7 +2804,7 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0) case CMODEL_MEDIUM: { rtx reg = gen_reg_rtx (Pmode); - if (TARGET_EXPLICIT_RELOCS) + if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) { emit_insn (gen_pcalau12i (Pmode, reg, loongarch_tls_symbol)); rtx call = gen_call_value_internal_1 (Pmode, v0, reg, @@ -2841,7 +2840,7 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0) case CMODEL_NORMAL: case CMODEL_MEDIUM: { - if (TARGET_EXPLICIT_RELOCS) + if (loongarch_explicit_relocs_p (SYMBOL_GOT_DISP)) { rtx high = gen_reg_rtx (Pmode); loongarch_emit_move (high, @@ -2935,7 +2934,7 @@ loongarch_legitimize_tls_address (rtx loc) tmp1 = gen_reg_rtx (Pmode); tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_IE); dest = gen_reg_rtx (Pmode); - if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) + if (loongarch_explicit_relocs_p (SYMBOL_TLS_IE)) { tmp3 = gen_reg_rtx (Pmode); rtx high = gen_rtx_HIGH (Pmode, copy_rtx (tmp2)); @@ -2992,7 +2991,7 @@ loongarch_legitimize_tls_address (rtx loc) tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_LE); dest = gen_reg_rtx (Pmode); - if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) + if (loongarch_explicit_relocs_p (SYMBOL_TLS_LE)) { tmp3 = gen_reg_rtx (Pmode); rtx high = gen_rtx_HIGH (Pmode, copy_rtx (tmp2)); diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-auto-tls-ld-gd.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-auto-tls-ld-gd.c new file mode 100644 index 000000000..35bd4570a --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-auto-tls-ld-gd.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fPIC -mexplicit-relocs=auto -mcmodel=extreme -fno-plt" } */ +/* { dg-final { scan-assembler-not "la.tls.\[lg\]d" { target tls_native } } } */ + +#include "./explicit-relocs-auto-tls-ld-gd.c" diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-auto-tls-ld-gd.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-auto-tls-ld-gd.c new file mode 100644 index 000000000..47bffae8a --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-auto-tls-ld-gd.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fPIC -mexplicit-relocs=auto -mcmodel=medium -fplt" } */ +/* { dg-final { scan-assembler-not "la.global" { target tls_native } } } */ + +#include "./explicit-relocs-auto-tls-ld-gd.c" -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2