[PATCH] Fix SRA access replacement renaming

Richard Guenther rguenther@suse.de
Fri Feb 3 11:19:00 GMT 2012


If we have something like

BIT_FIELD_REF <a.D.1707, 1, 0> = D.1722_3;

where a.D.1707 is of integer type then SRA will happily create
an SSA name replacement for a.D1707 resulting in invalid GIMPLE
IL with partial updates to SSA names (and crash later in the
verifiers).

The following patch cures this - I have not been able to come up
with a testcase with an unpatched trunk though.

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-02-03  Richard Guenther  <rguenther@suse.de>

	* tree-sra.c (create_access_replacement): Only rename the
	replacement if we can rewrite it into SSA form.  Properly
	mark register typed replacements that we cannot rewrite
	with TREE_ADDRESSABLE.

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c	(revision 183867)
+++ gcc/tree-sra.c	(working copy)
@@ -1908,13 +1908,19 @@ create_access_replacement (struct access
 
   repl = create_tmp_var (access->type, "SR");
   add_referenced_var (repl);
-  if (rename)
+  if (!access->grp_partial_lhs
+      && rename)
     mark_sym_for_renaming (repl);
 
-  if (!access->grp_partial_lhs
-      && (TREE_CODE (access->type) == COMPLEX_TYPE
-	  || TREE_CODE (access->type) == VECTOR_TYPE))
-    DECL_GIMPLE_REG_P (repl) = 1;
+  if (TREE_CODE (access->type) == COMPLEX_TYPE
+      || TREE_CODE (access->type) == VECTOR_TYPE)
+    {
+      if (!access->grp_partial_lhs)
+	DECL_GIMPLE_REG_P (repl) = 1;
+    }
+  else if (access->grp_partial_lhs
+	   && is_gimple_reg_type (access->type))
+    TREE_ADDRESSABLE (repl) = 1;
 
   DECL_SOURCE_LOCATION (repl) = DECL_SOURCE_LOCATION (access->base);
   DECL_ARTIFICIAL (repl) = 1;



More information about the Gcc-patches mailing list