mengqinggang <[email protected]> writes:
pushed as r17-2779-g3483ca0a0e7ab8.
> 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.
> ---
> gcc/config/loongarch/loongarch.cc | 1 -
> gcc/testsuite/gcc.target/loongarch/dtprel.c | 11 +++++++++++
> 2 files changed, 11 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.target/loongarch/dtprel.c
>
> diff --git a/gcc/config/loongarch/loongarch.cc
> b/gcc/config/loongarch/loongarch.cc
> index 998cfb9a26a..db5e8161f2f 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -7173,7 +7173,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 00000000000..d9c5479a19f
> --- /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;
> +}