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

login
register
mail settings
Submitter Uros Bizjak
Date July 28, 2011, 7:44 a.m.
Message ID <CAFULd4ZYdVgX_e4G77mJ9E34hAeDujYAB3LwtR_fRifc+2EH5A@mail.gmail.com>
Download mbox | patch
Permalink /patch/107197/
State New
Headers show

Comments

Uros Bizjak - July 28, 2011, 7:44 a.m.
On Thu, Jul 28, 2011 at 8:52 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> TLS on X32 is almost identical to TLS on x86-64.  The only difference is
>> x32 address space is 32bit.  That means TLS symbols can be in either
>> SImode or DImode with upper 32bit zero.  This patch updates
>> tls_global_dynamic_64 to support x32.  OK for trunk?

Please also change 64bit GNU2_TLS patterns, so -mtls-dialect=gnu2 will
also work.  Please see attached patch.

Uros.
H.J. Lu - July 28, 2011, 1:47 p.m.
On Thu, Jul 28, 2011 at 12:44 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 28, 2011 at 8:52 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>>> TLS on X32 is almost identical to TLS on x86-64.  The only difference is
>>> x32 address space is 32bit.  That means TLS symbols can be in either
>>> SImode or DImode with upper 32bit zero.  This patch updates
>>> tls_global_dynamic_64 to support x32.  OK for trunk?
>
> Please also change 64bit GNU2_TLS patterns, so -mtls-dialect=gnu2 will
> also work.  Please see attached patch.
>

Yes, it works.  Can you apply it?

Thanks.
H.J. Lu - July 28, 2011, 2:48 p.m.
On Thu, Jul 28, 2011 at 7:42 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 28, 2011 at 3:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>>>> TLS on X32 is almost identical to TLS on x86-64.  The only difference is
>>>>> x32 address space is 32bit.  That means TLS symbols can be in either
>>>>> SImode or DImode with upper 32bit zero.  This patch updates
>>>>> tls_global_dynamic_64 to support x32.  OK for trunk?
>>>
>>> Please also change 64bit GNU2_TLS patterns, so -mtls-dialect=gnu2 will
>>> also work.  Please see attached patch.
>>>
>>
>> Yes, it works.  Can you apply it?
>
> This is what I have committed:
>
> 2011-07-28  Uros Bizjak  <ubizjak@gmail.com>
>
>        PR target/47715
>        * config/i386/i386.md (*tls_global_dynamic_64): Remove mode from
>        tls_symbolic_operand check.  Update code sequence for TARGET_X32.
>        (tls_global_dynamic_64): Remove mode from tls_symbolic_operand check.
>        (tls_dynamic_gnu2_64): Ditto.
>        (*tls_dynamic_gnu2_lea_64): Ditto.
>        (*tls_dynamic_gnu2_call_64): Ditto.
>        (*tls_dynamic_gnu2_combine_64): Ditto.
>

It looks good.  I will check in

@@ -12341,15 +12345,16 @@
   return "call\t%P2";
 }
   [(set_attr "type" "multi")
-   (set_attr "length" "16")])
+   (set (attr "length")
+	(symbol_ref "TARGET_X32 ? 15 : 16"))])

since x32 is one byte shorter now.

Thanks.

Patch

Index: i386.md
===================================================================
--- i386.md	(revision 176860)
+++ i386.md	(working copy)
@@ -12327,7 +12327,7 @@ 
 	(call:DI
 	 (mem:QI (match_operand:DI 2 "constant_call_address_operand" "z"))
 	 (match_operand:DI 3 "" "")))
-   (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
+   (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
 	      UNSPEC_TLS_GD)]
   "TARGET_64BIT"
 {
@@ -12349,7 +12349,7 @@ 
 	  (call:DI
 	   (mem:QI (match_operand:DI 2 "constant_call_address_operand" ""))
 	   (const_int 0)))
-     (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
+     (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
 		UNSPEC_TLS_GD)])])
 
 (define_insn "*tls_local_dynamic_base_32_gnu"
@@ -12553,7 +12553,7 @@ 
 
 (define_expand "tls_dynamic_gnu2_64"
   [(set (match_dup 2)
-	(unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
+	(unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
 		   UNSPEC_TLSDESC))
    (parallel
     [(set (match_operand:DI 0 "register_operand" "")
@@ -12568,7 +12568,7 @@ 
 
 (define_insn "*tls_dynamic_lea_64"
   [(set (match_operand:DI 0 "register_operand" "=r")
-	(unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
+	(unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
 		   UNSPEC_TLSDESC))]
   "TARGET_64BIT && TARGET_GNU2_TLS"
   "lea{q}\t{%a1@TLSDESC(%%rip), %0|%0, %a1@TLSDESC[rip]}"
@@ -12579,7 +12579,7 @@ 
 
 (define_insn "*tls_dynamic_call_64"
   [(set (match_operand:DI 0 "register_operand" "=a")
-	(unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")
+	(unspec:DI [(match_operand 1 "tls_symbolic_operand" "")
 		    (match_operand:DI 2 "register_operand" "0")
 		    (reg:DI SP_REG)]
 		   UNSPEC_TLSDESC))
@@ -12598,7 +12598,7 @@ 
 		     (reg:DI SP_REG)]
 		    UNSPEC_TLSDESC)
 	 (const:DI (unspec:DI
-		    [(match_operand:DI 1 "tls_symbolic_operand" "")]
+		    [(match_operand 1 "tls_symbolic_operand" "")]
 		    UNSPEC_DTPOFF))))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_64BIT && TARGET_GNU2_TLS"