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]

[committed] Fix gimplification of structs with VLA fields (PR tree-optimization/39394)


Hi!

For structs with VLA fields as the one in the testcase below
we weren't gimplifying DECL_SIZE nor DECL_SIZE_UNIT, so it
contained expressions referencing possibly removed BLOCKs.

gimplify_vla_decl already calls gimplify_one_sizepos on
DECL_SIZE/DECL_SIZE_UNIT, so it was just (very rare) FIELD_DECLs that
didn't have these gimplified.

Bootstrapped/regtested on x86_64-linux, committed to trunk.

2009-03-09  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/39394
	* gimplify.c (gimplify_type_sizes): Gimplify DECL_SIZE and
	DECL_SIZE_UNIT of variable length FIELD_DECLs.

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

--- gcc/gimplify.c.jj	2009-03-04 20:06:31.000000000 +0100
+++ gcc/gimplify.c	2009-03-09 12:47:06.000000000 +0100
@@ -7141,6 +7141,8 @@ gimplify_type_sizes (tree type, gimple_s
 	if (TREE_CODE (field) == FIELD_DECL)
 	  {
 	    gimplify_one_sizepos (&DECL_FIELD_OFFSET (field), list_p);
+	    gimplify_one_sizepos (&DECL_SIZE (field), list_p);
+	    gimplify_one_sizepos (&DECL_SIZE_UNIT (field), list_p);
 	    gimplify_type_sizes (TREE_TYPE (field), list_p);
 	  }
       break;
--- gcc/testsuite/gcc.c-torture/compile/pr39394.c.jj	2009-03-09 12:49:50.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr39394.c	2009-03-09 12:49:34.000000000 +0100
@@ -0,0 +1,28 @@
+/* PR tree-optimization/39394 */
+
+char *p;
+int x;
+
+static inline void
+f1 (int n)
+{
+  asm volatile ("" : "=m" (*(struct { char x[n]; } *) p));
+}
+
+static inline void
+f2 (void)
+{
+  x ? f1 (1) : f1 (2);
+}
+
+static inline void
+f3 (void)
+{
+  f2 ();
+}
+
+void
+f4 (void)
+{
+  f3 ();
+}

	Jakub


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