[ARC] Fix emitting TLS symbols.
authorClaudiu Zissulescu <claziss@synopsys.com>
Mon, 22 Jul 2019 07:06:37 +0000 (09:06 +0200)
committerClaudiu Zissulescu <claziss@gcc.gnu.org>
Mon, 22 Jul 2019 07:06:37 +0000 (09:06 +0200)
When storing a TLS symbol to memory, always use an intermediate register to load it.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc.c (prepare_move_operands): Always use an
intermediate register when storing a TLS symbols.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* gcc/testsuite/gcc.target/arc/tls-2.c: New test.
* gcc/testsuite/gcc.target/arc/tls-3.c: Likewise.

From-SVN: r273657

gcc/ChangeLog
gcc/config/arc/arc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arc/tls-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arc/tls-3.c [new file with mode: 0644]

index 711a31ea597d1d41d4822dd682ca9a069ae00c66..078a7d722f600da4d2ee7b3d83fa866f2cc03c7f 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-22  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * config/arc/arc.c (prepare_move_operands): Always use an
+       intermediate register when storing a TLS symbols.
+
 2019-07-22  Stafford Horne  <shorne@gmail.com>
 
        * config/or1k/or1k.c (or1k_expand_compare): Check for int before
index 5decf916884c32c593fb4fe2b9d98419c2892064..71e65767ee1e0ee4fa3f6a091627597b89d309ad 100644 (file)
@@ -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);
index 12774c06466effc733f4efe6a5f7726693046fb7..31a9d33c66bcfba2fb32e13aafd59c4a67e1569c 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-22  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * gcc.target/arc/tls-2.c: New test.
+       * gcc.target/arc/tls-3.c: Likewise.
+
 2019-07-21  Marek Polacek  <polacek@redhat.com>
 
        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 (file)
index 0000000..3cec309
--- /dev/null
@@ -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 (file)
index 0000000..e78b5a2
--- /dev/null
@@ -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);
+}