Patchwork Fix SRA access replacement renaming

login
register
mail settings
Submitter Richard Guenther
Date Feb. 3, 2012, 11:19 a.m.
Message ID <alpine.LNX.2.00.1202031216550.4999@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/139354/
State New
Headers show

Comments

Richard Guenther - Feb. 3, 2012, 11:19 a.m.
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.

Patch

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;