diff mbox series

[2/2,ARC] Fix emitting TLS symbols.

Message ID 20190628133926.29980-2-claziss@gmail.com
State New
Headers show
Series [1/2,ARC] Fix and refurbish the interrupts. | expand

Commit Message

Claudiu Zissulescu June 28, 2019, 1:39 p.m. UTC
This is another issue found during smoke testing glibc.

When storing a TLS symbol to memory, always use an intermediate
register to load it.

Ok to apply?
Claudiu

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.
---
 gcc/config/arc/arc.c                 |  2 +-
 gcc/testsuite/gcc.target/arc/tls-2.c | 14 ++++++++++++++
 gcc/testsuite/gcc.target/arc/tls-3.c | 19 +++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/arc/tls-2.c
 create mode 100644 gcc/testsuite/gcc.target/arc/tls-3.c

Comments

Jeff Law June 28, 2019, 10:06 p.m. UTC | #1
On 6/28/19 7:39 AM, Claudiu Zissulescu wrote:
> This is another issue found during smoke testing glibc.
> 
> When storing a TLS symbol to memory, always use an intermediate
> register to load it.
> 
> Ok to apply?
> Claudiu
> 
> 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.
OK.  If it's dependent on 1/2 of this series, then obviously wait for
1/2 to be approved before applying.

jeff
diff mbox series

Patch

diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 910c8d2ad30..66a69628980 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -9272,7 +9272,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/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);
+}