[PATCH] Fix i?86 pic thunk generation (PR target/60568)

Jakub Jelinek jakub@redhat.com
Thu Mar 20 09:27:00 GMT 2014


Hi!

With -flto -fpic -m32 sometimes (unfortunately the testcase provided was
in form of *.o file with LTO bytecode, so can't be reduced), if the thunk
target doesn't bind locally we get ICE because we can't recog what
x86_output_mi_thunk creates.  The problem is that it doesn't
put UNSPEC_GOT into CONST and thus ix86_decompose_address refuses it.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux and
tested with the testcase that it doesn't ICE anymore and can be properly
assembled.  Ok for trunk?

2014-03-19  Jakub Jelinek  <jakub@redhat.com>

	PR target/60568
	* config/i386/i386.c (x86_output_mi_thunk): Surround UNSPEC_GOT
	into CONST, put pic register as first operand of PLUS.  Use
	gen_const_mem for both 32-bit and 64-bit PIC got loads.

--- gcc/config/i386/i386.c.jj	2014-03-17 20:02:31.000000000 +0100
+++ gcc/config/i386/i386.c	2014-03-20 06:40:05.713956057 +0100
@@ -38753,7 +38753,7 @@ x86_output_mi_thunk (FILE *file,
 	{
 	  tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOTPCREL);
 	  tmp = gen_rtx_CONST (Pmode, tmp);
-	  fnaddr = gen_rtx_MEM (Pmode, tmp);
+	  fnaddr = gen_const_mem (Pmode, tmp);
 	}
     }
   else
@@ -38773,8 +38773,9 @@ x86_output_mi_thunk (FILE *file,
 	  output_set_got (tmp, NULL_RTX);
 
 	  fnaddr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOT);
-	  fnaddr = gen_rtx_PLUS (Pmode, fnaddr, tmp);
-	  fnaddr = gen_rtx_MEM (Pmode, fnaddr);
+	  fnaddr = gen_rtx_CONST (Pmode, fnaddr);
+	  fnaddr = gen_rtx_PLUS (Pmode, tmp, fnaddr);
+	  fnaddr = gen_const_mem (Pmode, fnaddr);
 	}
     }
 

	Jakub



More information about the Gcc-patches mailing list