From: Claudiu Zissulescu Date: Mon, 22 Jul 2019 07:06:37 +0000 (+0200) Subject: [ARC] Fix emitting TLS symbols. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4be6c9b9a2085b32be37df4216c37b395c7bd1a2;p=gcc.git [ARC] Fix emitting TLS symbols. When storing a TLS symbol to memory, always use an intermediate register to load it. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.c (prepare_move_operands): Always use an intermediate register when storing a TLS symbols. gcc/ xxxx-xx-xx Claudiu Zissulescu * gcc/testsuite/gcc.target/arc/tls-2.c: New test. * gcc/testsuite/gcc.target/arc/tls-3.c: Likewise. From-SVN: r273657 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 711a31ea597..078a7d722f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-22 Claudiu Zissulescu + + * config/arc/arc.c (prepare_move_operands): Always use an + intermediate register when storing a TLS symbols. + 2019-07-22 Stafford Horne * config/or1k/or1k.c (or1k_expand_compare): Check for int before diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 5decf916884..71e65767ee1 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -8959,7 +8959,7 @@ prepare_move_operands (rtx *operands, machine_mode mode) if (GET_CODE (operands[1]) == SYMBOL_REF) { enum tls_model model = SYMBOL_REF_TLS_MODEL (operands[1]); - if (MEM_P (operands[0]) && flag_pic) + if (MEM_P (operands[0])) operands[1] = force_reg (mode, operands[1]); else if (model) operands[1] = arc_legitimize_tls_address (operands[1], model); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 12774c06466..31a9d33c66b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-22 Claudiu Zissulescu + + * gcc.target/arc/tls-2.c: New test. + * gcc.target/arc/tls-3.c: Likewise. + 2019-07-21 Marek Polacek PR c++/67853 diff --git a/gcc/testsuite/gcc.target/arc/tls-2.c b/gcc/testsuite/gcc.target/arc/tls-2.c new file mode 100644 index 00000000000..3cec309a0b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/tls-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ +/* { dg-skip-if "" { arc*-*-elf* } } */ +/* { dg-options "-O2" } */ + +typedef int type_a; +__thread int b; +int c; + +extern int bar (char *, int, int *, int, int *, char, type_a, int *, int *); +int foo (int *f, char buffer, type_a buflen, int *g) +{ + bar("", c, (int *)foo, 1, (int *)f, buffer, buflen, (int *)g, &b); +} diff --git a/gcc/testsuite/gcc.target/arc/tls-3.c b/gcc/testsuite/gcc.target/arc/tls-3.c new file mode 100644 index 00000000000..e78b5a22742 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/tls-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ +/* { dg-skip-if "" { arc*-*-elf* } } */ +/* { dg-options "-Os -fPIC" } */ + + +typedef struct +{ + int(a); + char b[]; +} type_c; + + +extern int bar (char *, int, char *); +static _Thread_local type_c d; +int foo(void) +{ + bar(d.b, 0, d.b); +}