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: PR target/39903: [4.4/4.5 Regression] ICE on flexible member


Hi,

construct_container isn't prepared to deal with

struct X {
  double d;
  double b[];
};

This patch fixes it.  I am testing it on Linux/Intel64. OK for
trunk and 4.4 if there are no regressions?

Thanks.


H.J.
----
gcc/

2009-04-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39903
	* config/i386/i386.c (construct_container): Don't call
	gen_reg_or_parallel with BLKmode for X86_64_SSE_CLASS,
	X86_64_SSESF_CLASS and X86_64_SSEDF_CLASS.

gcc/testsuite/

2009-04-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39903
	* gcc.dg/torture/pr39903-1.c: New.
	* gcc.dg/torture/pr39903-2.c: Likewise.

Index: gcc/testsuite/gcc.dg/torture/pr39903-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr39903-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr39903-1.c	(revision 0)
@@ -0,0 +1,24 @@
+/* PR target/39903 */
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi" } */
+
+struct X {
+  double d;
+  double b[];
+};
+
+struct X __attribute__((noinline))
+foo (double d)
+{
+  struct X x;
+  x.d = d;
+  return x;
+}
+extern void abort (void);
+int main()
+{
+  struct X x = foo(3.0);
+  if (x.d != 3.0)
+    abort ();
+  return 0;
+}
Index: gcc/testsuite/gcc.dg/torture/pr39903-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr39903-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr39903-2.c	(revision 0)
@@ -0,0 +1,24 @@
+/* PR target/39903 */
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi" } */
+
+struct X {
+  float d;
+  float b[];
+};
+
+struct X __attribute__((noinline))
+foo (float d)
+{
+  struct X x;
+  x.d = d;
+  return x;
+}
+extern void abort (void);
+int main()
+{
+  struct X x = foo(3.0);
+  if (x.d != 3.0)
+    abort ();
+  return 0;
+}
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 146817)
+++ gcc/config/i386/i386.c	(working copy)
@@ -5466,7 +5466,10 @@ construct_container (enum machine_mode m
       case X86_64_SSE_CLASS:
       case X86_64_SSESF_CLASS:
       case X86_64_SSEDF_CLASS:
-	return gen_reg_or_parallel (mode, orig_mode, SSE_REGNO (sse_regno));
+	if (mode != BLKmode)
+	  return gen_reg_or_parallel (mode, orig_mode, 
+				      SSE_REGNO (sse_regno));
+	break;
       case X86_64_X87_CLASS:
       case X86_64_COMPLEX_X87_CLASS:
 	return gen_rtx_REG (mode, FIRST_STACK_REG);


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