> Hmm, at -O0 we should be able to coalesce all SSA names of a
> DECL.  So in theory the following should work:

Yes, the attached patch introduces no regressions in the testsuite.  How 
robust is that though?  Do we need some checking for it?


        * cfgexpand.c (expand_used_vars): Allocate space for partitions based
        on PARM_DECLs or RESULT_DECLs only when optimization is enabled.
        * tree-outof-ssa.c (remove_ssa_form): Record which partitions contain
        a default def only when optimization is enabled.
        (finish_out_of_ssa): Adjust.


-- 
Eric Botcazou
Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 204678)
+++ cfgexpand.c	(working copy)
@@ -1610,9 +1610,13 @@ expand_used_vars (void)
 	  replace_ssa_name_symbol (var, (tree) *slot);
 	}
 
+      /* Always allocate space for partitions based on VAR_DECLs.  But for
+	 those based on PARM_DECLs or RESULT_DECLs, there is no need to do
+	 so if optimization is disabled because all the SSA_NAMEs based on
+	 these DECLs should have been coalesced into a single partition.  */
       if (TREE_CODE (SSA_NAME_VAR (var)) == VAR_DECL)
 	expand_one_var (var, true, true);
-      else
+      else if (optimize)
 	{
 	  /* This is a PARM_DECL or RESULT_DECL.  For those partitions that
 	     contain the default def (representing the parm or result itself)
Index: tree-outof-ssa.c
===================================================================
--- tree-outof-ssa.c	(revision 204678)
+++ tree-outof-ssa.c	(working copy)
@@ -999,15 +999,23 @@ remove_ssa_form (bool perform_ter, struc
 
   sa->map = map;
   sa->values = values;
-  sa->partition_has_default_def = BITMAP_ALLOC (NULL);
-  for (i = 1; i < num_ssa_names; i++)
+
+  /* If optimization is enabled, record which partitions contain a default
+     def.  If the underlying object is a PARM_DECL or RESULT_DECL, they'll
+     be assigned the canonical RTL location of the object; the other ones
+     will be assigned a stack temporary.  */
+  if (optimize)
     {
-      tree t = ssa_name (i);
-      if (t && SSA_NAME_IS_DEFAULT_DEF (t))
+      sa->partition_has_default_def = BITMAP_ALLOC (NULL);
+      for (i = 1; i < num_ssa_names; i++)
 	{
-	  int p = var_to_partition (map, t);
-	  if (p != NO_PARTITION)
-	    bitmap_set_bit (sa->partition_has_default_def, p);
+	  tree t = ssa_name (i);
+	  if (t && SSA_NAME_IS_DEFAULT_DEF (t))
+	    {
+	      int p = var_to_partition (map, t);
+	      if (p != NO_PARTITION)
+		bitmap_set_bit (sa->partition_has_default_def, p);
+	    }
 	}
     }
 }
@@ -1183,7 +1191,8 @@ finish_out_of_ssa (struct ssaexpand *sa)
   if (sa->values)
     BITMAP_FREE (sa->values);
   delete_var_map (sa->map);
-  BITMAP_FREE (sa->partition_has_default_def);
+  if (optimize)
+    BITMAP_FREE (sa->partition_has_default_def);
   memset (sa, 0, sizeof *sa);
 }
 

Reply via email to