[gcc r17-2779] LoongArch: Remove addend for .dtprelword and .dtpreldword

Chenghua Xu via Gcc-cvs <[email protected]> Wed, 29 Jul 2026 08:46:01 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:3483ca0a0e7ab82d1159cbf6e59f8642114535b7

commit r17-2779-g3483ca0a0e7ab82d1159cbf6e59f8642114535b7
Author: mengqinggang <[email protected]>
Date:   Thu Jul 9 16:02:52 2026 +0800

    LoongArch: Remove addend for .dtprelword and .dtpreldword
    
    LoongArch's tp register points to the start of the TLS block,
    so not need a 0x8000 offset.
    
    gcc/ChangeLog:
    
            * config/loongarch/loongarch.cc (loongarch_output_dwarf_dtprel):
            Remove 0x8000.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/loongarch/dtprel.c: New test.

Diff:
---
 gcc/config/loongarch/loongarch.cc           |  1 -
 gcc/testsuite/gcc.target/loongarch/dtprel.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 3f0666f360cd..b0f7abc04834 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -7212,7 +7212,6 @@ loongarch_output_dwarf_dtprel (FILE *file, int size, rtx x)
       gcc_unreachable ();
     }
   output_addr_const (file, x);
-  fputs ("+0x8000", file);
 }
 
 /* Implement ASM_OUTPUT_ASCII.  */
diff --git a/gcc/testsuite/gcc.target/loongarch/dtprel.c b/gcc/testsuite/gcc.target/loongarch/dtprel.c
new file mode 100644
index 000000000000..d9c5479a19fd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/dtprel.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+/* { dg-final { scan-assembler-not "0x8000" } } */
+/* { dg-final { scan-assembler ".dtpreld?word.*a\\s+.byte" } } */
+
+__thread int a;
+void
+f(void)
+{
+  a += 1;
+}