diff mbox

Fix debug info for modified parameter

Message ID 2240585.9X5lD7ePko@polaris
State New
Headers show

Commit Message

Eric Botcazou Nov. 12, 2013, 9:30 a.m. UTC
> 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.

Comments

Richard Biener Nov. 13, 2013, 9:51 a.m. UTC | #1
On Tue, Nov 12, 2013 at 10:30 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 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?

I think we rely on it elsewhere, like in coalesce_ssa_name ()
(even though we use MUST_COALESCE_COST - 1 which means we'll
not ICE if we are not able to coalesce).

Changing the coalesce cost to MUST_COALESCE_COST for
PARM_DECLs and RESULT_DECLs should add the required
checking (we'll ICE if we cannot honor that coalescing request).
Note that the code also has a !DECL_IGNORED_P check, so
eventually the expansion code change should restrict itself to
that as well.

But the patch is ok, you can followup with the coalesce cost change
and the !DECL_IGNORED_P checking (if you are not confident enough it
works as-is).

Thanks,
Richard.

>
>         * 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
diff mbox

Patch

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);
 }