public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Claudiu Zissulescu <claziss@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: fbedard@synopsys.com,	andrew.burgess@embecosm.com
Subject: [PATCH 2/2] [ARC] Fix emitting TLS symbols.
Date: Fri, 28 Jun 2019 13:39:00 -0000	[thread overview]
Message-ID: <20190628133926.29980-2-claziss@gmail.com> (raw)
In-Reply-To: <20190628133926.29980-1-claziss@gmail.com>

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

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);
+}
-- 
2.21.0

  reply	other threads:[~2019-06-28 13:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 13:40 [PATCH 1/2] [ARC] Fix and refurbish the interrupts Claudiu Zissulescu
2019-06-28 13:39 ` Claudiu Zissulescu [this message]
2019-06-28 22:06   ` [PATCH 2/2] [ARC] Fix emitting TLS symbols Jeff Law
2019-07-02 23:15 ` [PATCH 1/2] [ARC] Fix and refurbish the interrupts Jeff Law
2019-07-08  9:01   ` Claudiu Zissulescu
2019-07-08 18:20     ` Jeff Law
2019-07-09 16:37       ` claziss
2019-07-22 21:54         ` Jeff Law
2019-07-24 13:29           ` Claudiu Zissulescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628133926.29980-2-claziss@gmail.com \
    --to=claziss@gmail.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=fbedard@synopsys.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).