cfgexpand.c (expand_used_vars): Allocate space for partitions based on PARM_DECLs...
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 13 Nov 2013 12:15:47 +0000 (12:15 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 13 Nov 2013 12:15:47 +0000 (12:15 +0000)
* cfgexpand.c (expand_used_vars): Allocate space for partitions based
on PARM_DECLs or RESULT_DECLs only if they are ignored for debug info
or if optimization is enabled.
* tree-ssa-coalesce.c (coalesce_ssa_name): If optimization is disabled,
require that all the names based on a PARM_DECL or a RESULT_DECL that
isn't ignored for debug info be coalesced.

From-SVN: r204742

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/param-4.c [new file with mode: 0644]
gcc/tree-ssa-coalesce.c

index d03d52b..56d0397 100644 (file)
@@ -1,3 +1,12 @@
+2013-11-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * cfgexpand.c (expand_used_vars): Allocate space for partitions based
+       on PARM_DECLs or RESULT_DECLs only if they are ignored for debug info
+       or if optimization is enabled.
+       * tree-ssa-coalesce.c (coalesce_ssa_name): If optimization is disabled,
+       require that all the names based on a PARM_DECL or a RESULT_DECL that
+       isn't ignored for debug info be coalesced.
+
 2013-11-13  Jan-Benedict Glaw  <jbglaw@lug-owl.de>
 
        * config/c6x/c6x.c: Include "gimple-expr.h".
index 4e622c0..de7a7b3 100644 (file)
@@ -1610,9 +1610,15 @@ 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 and which matter for the
+        debug info, there is no need to do so if optimization is disabled
+        because all the SSA_NAMEs based on these DECLs have been coalesced
+        into a single partition, which is thus assigned the canonical RTL
+        location of the DECLs.  */
       if (TREE_CODE (SSA_NAME_VAR (var)) == VAR_DECL)
        expand_one_var (var, true, true);
-      else
+      else if (DECL_IGNORED_P (SSA_NAME_VAR (var)) || optimize)
        {
          /* This is a PARM_DECL or RESULT_DECL.  For those partitions that
             contain the default def (representing the parm or result itself)
index df1ee9a..d32d1be 100644 (file)
@@ -1,3 +1,7 @@
+2013-11-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/guality/param-4.c: New test.
+
 2013-11-13  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/c11-complex-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/guality/param-4.c b/gcc/testsuite/gcc.dg/guality/param-4.c
new file mode 100644 (file)
index 0000000..a76b251
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-g" } */
+/* { dg-skip-if "" { *-*-* }  { "*" } { "-O0" } } */
+
+void
+foo (int i)
+{
+  int j = 0;
+  i = 1;
+  j = j + 1;  /* BREAK */
+}
+
+int
+main (void)
+{
+  foo (0);
+  return 0;
+}
+
+/* { dg-final { gdb-test 10 "i" "1" } } */
\ No newline at end of file
index c445c78..252fc33 100644 (file)
@@ -1256,8 +1256,8 @@ coalesce_ssa_name (void)
   cl = create_coalesce_list ();
   map = create_outofssa_var_map (cl, used_in_copies);
 
-  /* We need to coalesce all names originating same SSA_NAME_VAR
-     so debug info remains undisturbed.  */
+  /* If optimization is disabled, we need to coalesce all the names originating
+     from the same SSA_NAME_VAR so debug info remains undisturbed.  */
   if (!optimize)
     {
       hash_table <ssa_name_var_hash> ssa_name_hash;
@@ -1278,8 +1278,16 @@ coalesce_ssa_name (void)
                *slot = a;
              else
                {
-                 add_coalesce (cl, SSA_NAME_VERSION (a), SSA_NAME_VERSION (*slot),
-                               MUST_COALESCE_COST - 1);
+                 /* If the variable is a PARM_DECL or a RESULT_DECL, we
+                    _require_ that all the names originating from it be
+                    coalesced, because there must be a single partition
+                    containing all the names so that it can be assigned
+                    the canonical RTL location of the DECL safely.  */
+                 const int cost
+                   = TREE_CODE (SSA_NAME_VAR (a)) == VAR_DECL
+                     ? MUST_COALESCE_COST - 1 : MUST_COALESCE_COST;
+                 add_coalesce (cl, SSA_NAME_VERSION (a),
+                               SSA_NAME_VERSION (*slot), cost);
                  bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (a));
                  bitmap_set_bit (used_in_copies, SSA_NAME_VERSION (*slot));
                }