From patchwork Mon Jan 22 18:42:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 84570 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 061E63858284 for ; Mon, 22 Jan 2024 18:44:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 6C9533858417 for ; Mon, 22 Jan 2024 18:43:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C9533858417 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6C9533858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705949015; cv=none; b=lSCF6uWUe2Q0Ic5/HS94xr7c2DSy0WJe/KLaiZY1YUp1BKDLwJPoGo8oToz06DwgZ77MyhYcYjMiEHGBPz1gFTEtczd3vuYRrh26Zo3diq1Z1vLxtdJrG2Mq+AfUFP3DAYpoktNW+eRFtVTA37qkuaomV6uST0uRuGxseR5rE4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705949015; c=relaxed/simple; bh=NqWIfUCAwldt8wyjL6uyT/+/+7kgCTNbHmE5ZKZs4FE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MmU32lDHQza0iycuw7DVaH8KRvqYfgoPlQuT4Im9yPIffYeUAesOuSNDArtNhRYSODbECAi6zOEiDuL+4Qvl8zg8U17w/dHtjzFePulsX45V1i5GowOzJeGHmXq3kr2ugb4LvGvLN/ZRbkWQCtJfZuht2rTGQxkyf6LZbKxrmxU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1705949008; bh=NqWIfUCAwldt8wyjL6uyT/+/+7kgCTNbHmE5ZKZs4FE=; h=From:To:Cc:Subject:Date:From; b=HurGyEN4krLkwscG10Hfp6w0HX3R5PfJgdXYWQjMqjdkcaycci/NxrPlh6HM7ojJS nM+8qEp8Hl+WO4Dp9pMLptyerNtQgChMQSjGcVraAqJtJZgGD4kV7ciLVdgw3Iu9XC ZGW5qleNNfbR5B8+j840ju60EUH4/EBX/zn7rR4g= Received: from stargazer.. (unknown [IPv6:240e:358:119a:ce00:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 4FE3E670B9; Mon, 22 Jan 2024 13:43:18 -0500 (EST) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: chenglulu , i@xen0n.name, xuchenghua@loongson.cn, mengqinggang@loongson.cn, Xi Ruoyao Subject: [PATCH] LoongArch: Disable explicit reloc for TLS LD/GD with -mexplicit-relocs=auto Date: Tue, 23 Jan 2024 02:42:25 +0800 Message-ID: <20240122184259.1153112-1-xry111@xry111.site> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Binutils 2.42 supports TLS LD/GD relaxation which requires the assembler macro. gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_explicit_relocs_p): If la_opt_explicit_relocs is EXPLICIT_RELOCS_AUTO, return false for SYMBOL_TLS_LDM and SYMBOL_TLS_GD. (loongarch_call_tls_get_addr): Do not split symbols of SYMBOL_TLS_LDM or SYMBOL_TLS_GD if la_opt_explicit_relocs is EXPLICIT_RELOCS_AUTO. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c: Check for la.tls.ld and la.tls.gd. --- Bootstrapped & regtested on loongarch64-linux-gnu. Ok for trunk? gcc/config/loongarch/loongarch.cc | 9 ++++----- .../loongarch/explicit-relocs-auto-tls-ld-gd.c | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 82467474288..58df0b5637d 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -1970,11 +1970,10 @@ loongarch_explicit_relocs_p (enum loongarch_symbol_type type) { case SYMBOL_TLS_IE: case SYMBOL_TLS_LE: - case SYMBOL_TLSGD: - case SYMBOL_TLSLDM: case SYMBOL_PCREL64: - /* The linker don't know how to relax TLS accesses or 64-bit - pc-relative accesses. */ + /* TLS IE cannot be relaxed. TLS LE relaxation does not require + using the assembly macro. The linker 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 @@ -2789,7 +2788,7 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0) start_sequence (); - if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) + if (la_opt_explicit_relocs == EXPLICIT_RELOCS_ALWAYS) { /* Split tls symbol to high and low. */ rtx high = gen_rtx_HIGH (Pmode, copy_rtx (loc)); diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c index 957ff98df62..ca55fcfc53e 100644 --- a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c +++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c @@ -6,4 +6,5 @@ extern __thread int b __attribute__((visibility("default"))); int test() { return a + b; } -/* { dg-final { scan-assembler-not "la.tls" { target tls_native } } } */ +/* { dg-final { scan-assembler "la\\.tls\\.ld" { target tls_native } } } */ +/* { dg-final { scan-assembler "la\\.tls\\.gd" { target tls_native } } } */