]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-cfg.c (mark_used_vars): New function.
authorRichard Guenther <rguenther@suse.de>
Fri, 2 Dec 2005 11:56:35 +0000 (11:56 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 2 Dec 2005 11:56:35 +0000 (11:56 +0000)
2005-12-02  Richard Guenther  <rguenther@suse.de>

* tree-cfg.c (mark_used_vars): New function.
(dump_function_to_file): Dump only used VAR_DECLs.

* gcc.dg/tree-ssa/20031106-6.c: Remove XFAIL.

From-SVN: r107885

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20031106-6.c
gcc/tree-cfg.c

index b583ee5f02886f98bd651588e46ed7a66dd7d0b3..c949c5fa4af8937943367cb2745faf60061711cd 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-02  Richard Guenther  <rguenther@suse.de>
+
+       * tree-cfg.c (mark_used_vars): New function.
+       (dump_function_to_file): Dump only used VAR_DECLs.
+
 2005-12-02  Richard Guenther  <rguenther@suse.de>
 
        * convert.c (convert_to_integer): Fix compare for nonpositive
index b5d0daa2cac5dcf2756b9eb1ba4b6187beb26c80..27a310f604c227449962da574b91747e9ff152aa 100644 (file)
@@ -1,3 +1,7 @@
+2005-12-02  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/20031106-6.c: Remove XFAIL.
+
 2005-12-02  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * gcc.dg/lvalue-2.c (f0): Put "error: " marker back.
index 6d15c7b50530c844ea7e5b273d1dea54411302c9..8708fe12dcf296d280002e3e3a25d80fc2a6e077 100644 (file)
@@ -25,5 +25,5 @@ struct s foo (struct s r)
 
 /* There should be no references to any of "temp_struct*"
    temporaries.  */
-/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "optimized" } } */
index 13868e99e61ea00740e33d08cf301caa44ec53bd..497715abac0020480586b329b00154b5b62c3889 100644 (file)
@@ -4425,6 +4425,26 @@ tree_duplicate_sese_region (edge entry, edge exit,
 }
 
 
+static tree
+mark_used_vars (tree *tp, int *walk_subtrees, void *used_vars_)
+{
+  bitmap *used_vars = (bitmap *)used_vars_;
+
+  if (walk_subtrees
+      && IS_TYPE_OR_DECL_P (*tp))
+    *walk_subtrees = 0;
+
+  if (!SSA_VAR_P (*tp))
+    return NULL_TREE;
+
+  if (TREE_CODE (*tp) == SSA_NAME)
+    bitmap_set_bit (*used_vars, DECL_UID (SSA_NAME_VAR (*tp)));
+  else
+    bitmap_set_bit (*used_vars, DECL_UID (*tp));
+
+  return NULL_TREE;
+}
+
 /* Dump FUNCTION_DECL FN to file FILE using FLAGS (see TDF_* in tree.h)  */
 
 void
@@ -4459,18 +4479,47 @@ dump_function_to_file (tree fn, FILE *file, int flags)
      BIND_EXPRs, so display them separately.  */
   if (cfun && cfun->decl == fn && cfun->unexpanded_var_list)
     {
+      bitmap used_vars = BITMAP_ALLOC (NULL);
       ignore_topmost_bind = true;
 
+      /* Record vars we'll use dumping the functions tree.  */
+      if (cfun->cfg && basic_block_info)
+       {
+         FOR_EACH_BB (bb)
+           {
+             block_stmt_iterator bsi;
+             for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
+               walk_tree (bsi_stmt_ptr (bsi), mark_used_vars,
+                          &used_vars, NULL);
+           }
+         for (vars = cfun->unexpanded_var_list; vars;
+              vars = TREE_CHAIN (vars))
+           {
+             var = TREE_VALUE (vars);
+             if (TREE_CODE (var) == VAR_DECL
+                 && DECL_INITIAL (var)
+                 && bitmap_bit_p (used_vars, DECL_UID (var)))
+               walk_tree (&DECL_INITIAL (var), mark_used_vars,
+                          &used_vars, NULL);
+           }
+       }
+
+      /* Dump used vars.  */
       fprintf (file, "{\n");
       for (vars = cfun->unexpanded_var_list; vars; vars = TREE_CHAIN (vars))
        {
          var = TREE_VALUE (vars);
+         if (cfun->cfg && basic_block_info
+             && !bitmap_bit_p (used_vars, DECL_UID (var)))
+            continue;
 
          print_generic_decl (file, var, flags);
          fprintf (file, "\n");
 
          any_var = true;
        }
+
+      BITMAP_FREE (used_vars);
     }
 
   if (cfun && cfun->decl == fn && cfun->cfg && basic_block_info)