This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Remove unused VAR_DECLs from dump files
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Aug 2005 18:15:55 +0200 (CEST)
- Subject: [PATCH] Remove unused VAR_DECLs from dump files
After trying to remove these from our datastructures for real
with no success, this is the simpler approach of just not cluttering
the dump-files with them.
It still saves about half of the space for a full -fdump-tree-all
compile of tramp3d and shrinks single dump files down to about
20% of their size.
Bootstrapped on x86_64-unknown-linux-gnu, checking in progress.
Ok for mainline, even at stage3?
Thanks,
Richard.
:ADDPATCH:
2005-08-03 Richard Guenther <rguenther@suse.de>
* tree-cfg.c (mark_used_vars): New function.
(dump_function_to_file): Dump only used VAR_DECLs.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.212
diff -c -3 -p -r2.212 tree-cfg.c
*** tree-cfg.c 28 Jul 2005 07:41:22 -0000 2.212
--- tree-cfg.c 3 Aug 2005 16:12:01 -0000
*************** tree_duplicate_sese_region (edge entry,
*** 4372,4377 ****
--- 4372,4397 ----
}
+ 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
*************** dump_function_to_file (tree fn, FILE *fi
*** 4406,4423 ****
--- 4426,4467 ----
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. */
+ 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 (!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)