[x32] PATCH: PR target/47715: [x32] TLS doesn't work
H.J. Lu
hongjiu.lu@intel.com
Fri Feb 18 03:48:00 GMT 2011
On Mon, Feb 14, 2011 at 10:35:12AM -0800, H.J. Lu wrote:
> On Sun, Feb 13, 2011 at 03:22:51PM -0800, H.J. Lu wrote:
> > Hi,
> >
> > ix86_expand_move has
> >
> > tmp = expand_simple_binop (Pmode, PLUS, tmp, addend, op0, 1, OPTAB_DIRECT);
> > if (tmp == op0)
> > return;
> >
> > It never checks the case of tmp != op0. This patch fixes it.
> >
> > From 44741a1c97a7fec7c98702d217ac284856c75621 Mon Sep 17 00:00:00 2001
> > From: H.J. Lu <hjl.tools@gmail.com>
> > Date: Sun, 13 Feb 2011 15:09:50 -0800
> > Subject: [PATCH 3/3] Properly support TLS symbol in ix86_expand_move.
> >
> > ---
> > gcc/ChangeLog.x32 | 6 ++++++
> > gcc/config/i386/i386.c | 26 +++++++++++++++++---------
> > gcc/testsuite/ChangeLog.x32 | 5 +++++
> > gcc/testsuite/gcc.target/i386/pr47715-3.c | 17 +++++++++++++++++
> > 4 files changed, 45 insertions(+), 9 deletions(-)
> > create mode 100644 gcc/testsuite/gcc.target/i386/pr47715-3.c
> >
> > diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
> > index dda2a10..ec8aa23 100644
> > --- a/gcc/ChangeLog.x32
> > +++ b/gcc/ChangeLog.x32
> > @@ -1,5 +1,11 @@
> > 2011-02-13 H.J. Lu <hongjiu.lu@intel.com>
> >
> > + PR target/47715
> > + * config/i386/i386.c (ix86_expand_move): Properly support TLS
> > + symbol.
> > +
We should always use legitimized plus const symbol reference. Checked
into x32 branch.
H.J.
---
diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 4219032..7a447a9 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,9 @@
+2011-02-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/47715
+ * config/i386/i386.c (ix86_expand_move): Always use legitimized
+ plus const symbol reference.
+
2011-02-16 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/linux64.h (GLIBC_DYNAMIC_LINKERX32): Update
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fd08340..9794e6a 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -15520,13 +15520,20 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
}
}
+ if (symbol1)
+ {
+ if (GET_MODE (symbol1) != mode)
+ symbol1 = convert_to_mode (mode, symbol1, 1);
+ emit_insn (gen_rtx_SET (VOIDmode, op0, symbol1));
+ return;
+ }
+
if ((flag_pic || MACHOPIC_INDIRECT)
&& (mode == Pmode || mode == ptr_mode)
&& symbolic_operand (op1, mode))
{
if (TARGET_MACHO && !TARGET_64BIT)
{
- gcc_assert (symbol1 == NULL);
#if TARGET_MACHO
/* dynamic-no-pic */
if (MACHOPIC_INDIRECT)
@@ -15563,8 +15570,6 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
}
else
{
- if (symbol1 != NULL)
- op1 = symbol1;
if (MEM_P (op0))
op1 = force_reg (mode, op1);
else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index c60d7ce..3125d83 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@
+2011-02-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/47715
+ * gcc.target/i386/pr47715-4.c: New.
+
2011-02-16 H.J. Lu <hongjiu.lu@intel.com>
PR target/47766
diff --git a/gcc/testsuite/gcc.target/i386/pr47715-4.c b/gcc/testsuite/gcc.target/i386/pr47715-4.c
new file mode 100644
index 0000000..aa9026c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47715-4.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+struct gomp_team_state
+{
+ struct gomp_team_state *prev_ts;
+ unsigned team_id;
+ unsigned level;
+};
+struct gomp_thread
+{
+ void *data;
+ struct gomp_team_state ts;
+};
+extern __thread struct gomp_thread gomp_tls_data;
+int
+foo (int level)
+{
+ struct gomp_team_state *ts = &gomp_tls_data.ts;
+ if (level < 0 || level > ts->level)
+ return -1;
+ return ts->team_id;
+}
More information about the Gcc-patches
mailing list