Patchwork [x32] PATCH: PR target/47403: [x32] TLS doesn't work

login
register
mail settings
Submitter H.J. Lu
Date Jan. 21, 2011, 6:07 p.m.
Message ID <20110121180709.GA31172@intel.com>
Download mbox | patch
Permalink /patch/79877/
State New
Headers show

Comments

H.J. Lu - Jan. 21, 2011, 6:07 p.m.
Hi,

I checked in this patch to support TLS.

H.J.
---
commit 616596d6e7c882e9ad3822ef6c0158604e9ce981
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 21 10:04:19 2011 -0800

    Call convert_to_mode on legitimize_tls_address retuen if needed.
Dave Korn - Jan. 22, 2011, 3:57 a.m.
On 21/01/2011 18:07, H.J. Lu wrote:

> +	on legitimize_tls_address retuen if needed.

  Typo "retuen", for when you have a moment.

    cheers,
      DaveK
H.J. Lu - Jan. 22, 2011, 4:44 a.m.
On Fri, Jan 21, 2011 at 7:57 PM, Dave Korn <dave.korn.cygwin@gmail.com> wrote:
> On 21/01/2011 18:07, H.J. Lu wrote:
>
>> +     on legitimize_tls_address retuen if needed.
>
>  Typo "retuen", for when you have a moment.
>

Thanks.  Fixed.

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index f2f16ac..2b40839 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,9 @@ 
+2011-01-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47403
+	* config/i386/i386.c (ix86_expand_move): Call convert_to_mode
+	on legitimize_tls_address retuen if needed.
+
 2011-01-20  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47381
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b57b4c6..8427390 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -15290,6 +15290,8 @@  ix86_expand_move (enum machine_mode mode, rtx operands[])
       if (model)
 	{
 	  op1 = legitimize_tls_address (op1, model, true);
+	  if (GET_MODE (op1) != mode)
+	    op1 = convert_to_mode (mode, op1, 1);
 	  op1 = force_operand (op1, op0);
 	  if (op1 == op0)
 	    return;
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 371f822..4e2ef81 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@ 
+2011-01-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47403
+	* gcc.target/i386/pr47403-1.c: New.
+
 2011-01-20  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47381
diff --git a/gcc/testsuite/gcc.target/i386/pr47403-1.c b/gcc/testsuite/gcc.target/i386/pr47403-1.c
new file mode 100644
index 0000000..5d956df
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr47403-1.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec")));
+;
+int *
+__errno_location (void)
+{
+  return &__libc_errno;
+}