diff mbox

Fix ICE with -fpie (PR target/65593)

Message ID 20150327170813.GO1746@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 27, 2015, 5:08 p.m. UTC
Hi!

For %rip addressing, we only can use disp32 and thus can add
constants to the symbol/label, but not a register etc., as
there is no instruction supporting (plus (symbol_ref) (reg))
for PIC.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-03-27  Jakub Jelinek  <jakub@redhat.com>

	PR target/65593
	* config/i386/i386.c (legitimize_pic_address): If base
	is SYMBOL_REF or LABEL_REF using %rip addressing, force
	it to reg to avoid PLUS of SYMBOL_REF/LABEL_REF and register.

	* gcc.c-torture/compile/pr65593.c: New test.


	Jakub

Comments

Uros Bizjak March 27, 2015, 5:17 p.m. UTC | #1
On Fri, Mar 27, 2015 at 6:08 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> For %rip addressing, we only can use disp32 and thus can add
> constants to the symbol/label, but not a register etc., as
> there is no instruction supporting (plus (symbol_ref) (reg))
> for PIC.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK for trunk and release branches.

Thanks,
Uros.
diff mbox

Patch

--- gcc/config/i386/i386.c.jj	2015-03-23 16:31:27.000000000 +0100
+++ gcc/config/i386/i386.c	2015-03-27 14:19:54.646117550 +0100
@@ -13881,6 +13881,12 @@  legitimize_pic_address (rtx orig, rtx re
 		}
 	      else
 		{
+		  /* For %rip addressing, we have to use just disp32, not
+		     base nor index.  */
+		  if (TARGET_64BIT
+		      && (GET_CODE (base) == SYMBOL_REF
+			  || GET_CODE (base) == LABEL_REF))
+		    base = force_reg (mode, base);
 		  if (GET_CODE (new_rtx) == PLUS
 		      && CONSTANT_P (XEXP (new_rtx, 1)))
 		    {
--- gcc/testsuite/gcc.c-torture/compile/pr65593.c.jj	2015-03-27 14:40:55.973767411 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr65593.c	2015-03-27 14:42:19.697417036 +0100
@@ -0,0 +1,4 @@ 
+/* PR target/65593 */
+/* { dg-additional-options "-fpie" { target pie } } */
+
+#include "pr20928.c"