@@ -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.
+
+2011-02-13 H.J. Lu <hongjiu.lu@intel.com>
+
* config/i386/morestack.S: Properly check __x86_64__ and
__LP64__.
@@ -15403,6 +15403,7 @@ void
ix86_expand_move (enum machine_mode mode, rtx operands[])
{
rtx op0, op1;
+ rtx symbol1 = NULL;
enum tls_model model;
op0 = operands[0];
@@ -15430,21 +15431,20 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
{
rtx addend = XEXP (XEXP (op1, 0), 1);
rtx symbol = XEXP (XEXP (op1, 0), 0);
- rtx tmp = NULL;
model = SYMBOL_REF_TLS_MODEL (symbol);
if (model)
- tmp = legitimize_tls_address (symbol, model, true);
+ symbol1 = legitimize_tls_address (symbol, model, true);
else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
&& SYMBOL_REF_DLLIMPORT_P (symbol))
- tmp = legitimize_dllimport_symbol (symbol, true);
+ symbol1 = legitimize_dllimport_symbol (symbol, true);
- if (tmp)
+ if (symbol1)
{
- tmp = force_operand (tmp, NULL);
- tmp = expand_simple_binop (Pmode, PLUS, tmp, addend,
- op0, 1, OPTAB_DIRECT);
- if (tmp == op0)
+ symbol1 = force_operand (symbol1, NULL);
+ symbol1 = expand_simple_binop (Pmode, PLUS, symbol1, addend,
+ op0, 1, OPTAB_DIRECT);
+ if (symbol1 == op0)
return;
}
}
@@ -15455,6 +15455,7 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
{
if (TARGET_MACHO && !TARGET_64BIT)
{
+ gcc_assert (symbol1 == NULL);
#if TARGET_MACHO
/* dynamic-no-pic */
if (MACHOPIC_INDIRECT)
@@ -15491,7 +15493,13 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
}
else
{
- if (MEM_P (op0))
+ if (symbol1 != NULL)
+ {
+ op1 = symbol1;
+ if (GET_MODE (op1) != mode)
+ op1 = convert_to_mode (mode, op1, 1);
+ }
+ else if (MEM_P (op0))
op1 = force_reg (mode, op1);
else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
{
@@ -1,3 +1,8 @@
+2011-02-13 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/47715
+ * gcc.target/i386/pr47715-3.c: New.
+
2011-02-12 H.J. Lu <hongjiu.lu@intel.com>
PR target/47715
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -fPIC" } */
+
+struct initial_sp
+{
+ void *sp;
+ long len;
+};
+__thread
+struct initial_sp __morestack_initial_sp;
+void bar (void *);
+void
+foo ()
+{
+ bar (&__morestack_initial_sp.len);
+}
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