Patchwork [RFA,i386] : Fix gcc.target/i386/pr53249.c on Sun targets

login
register
mail settings
Submitter Uros Bizjak
Date May 24, 2012, 4:44 p.m.
Message ID <CAFULd4YKyQJHesPJRhKAg4+Hy-0AoLet9or5oGknxE=K+jsjzQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/161161/
State New
Headers show

Comments

Uros Bizjak - May 24, 2012, 4:44 p.m.
Hello!

Currently gcc fails to compile following test from the testsuite [1]:

FAIL: gcc.target/i386/pr53249.c (test for excess errors)

We are trying to compile X32 specific test, but the special pattern
that was introduced to handle certain sun assembler limitation, is not
prepared to handle X32.

The patch avoids this special pattern for X32 target. X32 is currently
supported only with gnu tools, and if/when sun tools will support X32
target, they will certainly fix the limitation which allows TP loads
to AX register only.

2012-05-24  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (legitimize_tls_address) <TLS_MODEL_INITIAL_EXEC>:
	Generate tls_initial_exec_64_sun insn only when !TARGET_X32.

Patch was tested by looking at the assembler of the failing test:

gomp_end_task:
.LFB0:
        movl    %fs:0, %edx
        movq    gomp_tls_data@gottpoff(%rip), %rax
        movl    4(%rdx,%rax), %ecx
        movl    (%ecx), %ecx
        movl    %ecx, 4(%edx,%eax)
        ret

OK for mainline?

[1] http://gcc.gnu.org/ml/gcc-testresults/2012-05/msg02028.html

Uros.
Rainer Orth - May 25, 2012, 1:57 p.m.
Hi Uros,

> Currently gcc fails to compile following test from the testsuite [1]:
>
> FAIL: gcc.target/i386/pr53249.c (test for excess errors)
>
> We are trying to compile X32 specific test, but the special pattern
> that was introduced to handle certain sun assembler limitation, is not
> prepared to handle X32.
>
> The patch avoids this special pattern for X32 target. X32 is currently
> supported only with gnu tools, and if/when sun tools will support X32
> target, they will certainly fix the limitation which allows TP loads
> to AX register only.

I'll give the patch a whirl in my regular bootstraps this weekend.

The Sun ld limitation is fixed in recent versions (at least Solaris 11,
perhaps also backported to S10) and I do have a patch to detect this and
turn off TARGET_SUN_TLS appropriately.  Unfortunately, there's still a
corner case in 64-bit TLS-IE handling that isn't handled correctly, but
I haven't yet found to time to fully investigate this.

Thanks.
	Rainer

Patch

Index: i386.c
===================================================================
--- i386.c	(revision 187841)
+++ i386.c	(working copy)
@@ -12811,13 +12811,13 @@  legitimize_tls_address (rtx x, enum tls_model mode
     case TLS_MODEL_INITIAL_EXEC:
       if (TARGET_64BIT)
 	{
-	  if (TARGET_SUN_TLS)
+	  if (TARGET_SUN_TLS && !TARGET_X32)
 	    {
 	      /* The Sun linker took the AMD64 TLS spec literally
 		 and can only handle %rax as destination of the
 		 initial executable code sequence.  */
 
-	      dest = gen_reg_rtx (Pmode);
+	      dest = gen_reg_rtx (DImode);
 	      emit_insn (gen_tls_initial_exec_64_sun (dest, x));
 	      return dest;
 	    }