This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix var-tracking ICEs due to i?86 delegitimization bug (PR target/47201)


Hi!

delegitimize_address hook should never return NULL, it should either
return a simplified rtx, or the original one.  But when simplify_gen_subreg
is called, it can fail on questionable code like the attached one, where
it was mem:SF of a GOTPCREL address, which ought to be
simplified into lowpart SFmode subreg of DImode symbol_ref, but target
doesn't allow that.  For var-tracking/debuginfo purposes we actually
can handle any subregs, but delegitimization hook is used in other places
too.
So fixed by returning the original x if simplification failed.

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

2011-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/47201
	* config/i386/i386.c (ix86_delegitimize_address): If
	simplify_gen_subreg fails, return orig_x.

	* gcc.dg/pr47201.c: New test.

--- gcc/config/i386/i386.c.jj	2011-01-06 10:21:47.000000000 +0100
+++ gcc/config/i386/i386.c	2011-01-07 09:50:23.000000000 +0100
@@ -13154,7 +13154,11 @@ ix86_delegitimize_address (rtx x)
 	return ix86_delegitimize_tls_address (orig_x);
       x = XVECEXP (XEXP (x, 0), 0, 0);
       if (GET_MODE (orig_x) != Pmode)
-	return simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
+	{
+	  x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
+	  if (x == NULL_RTX)
+	    return orig_x;
+	}
       return x;
     }
 
@@ -13223,7 +13227,11 @@ ix86_delegitimize_address (rtx x)
 	return orig_x;
     }
   if (GET_MODE (orig_x) != Pmode && MEM_P (orig_x))
-    return simplify_gen_subreg (GET_MODE (orig_x), result, Pmode, 0);
+    {
+      result = simplify_gen_subreg (GET_MODE (orig_x), result, Pmode, 0);
+      if (result == NULL_RTX)
+	return orig_x;
+    }
   return result;
 }
 
--- gcc/testsuite/gcc.dg/pr47201.c.jj	2011-01-07 09:57:46.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr47201.c	2011-01-07 09:57:37.000000000 +0100
@@ -0,0 +1,18 @@
+/* PR target/47201 */
+/* { dg-do compile } */
+/* { dg-options "-O -fpic -g" { target fpic } } */
+
+union U
+{
+  __UINTPTR_TYPE__ m;
+  float d;
+} u;
+
+int
+foo (void)
+{
+  union U v = {
+    (__UINTPTR_TYPE__)&u
+  };
+  return u.d == v.d;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]