This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Add -fdump-tree-optimized [patch]
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- Date: Wed, 25 Sep 2002 20:59:25 -0400
- Subject: [tree-ssa] Add -fdump-tree-optimized [patch]
- Organization: Red Hat Canada
Contributed by Steven Bosscher. It dumps the function after all
the optimization passes have been applied.
Steven, I slightly modified the patch to work inside
optimize_function_tree instead of c-decl.c
Tested by re-building stage1 cc1 on x86.
Diego.
2002-09-25 Steven Bosscher <s.bosscher@student.tudelft.nl>
* Makefile.in (tree): Add dependency on c-tree.h
* tree-optimize.c: Include c-tree.h
(optimize_function_tree): React to -fdump-tree-optimized.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.33
diff -d -u -p -r1.903.2.33 Makefile.in
--- Makefile.in 25 Sep 2002 15:30:24 -0000 1.903.2.33
+++ Makefile.in 26 Sep 2002 00:50:08 -0000
@@ -1397,7 +1397,7 @@ tree-dfa.o : tree-dfa.c tree-optimize.h
tree-optimize.o : tree-optimize.c tree-optimize.h tree-flow.h $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(EXPR_H) \
$(GGC_H) output.h diagnostic.h ssa.h errors.h flags.h tree-alias-common.h \
- tree-dchain.h $(C_COMMON_H)
+ tree-dchain.h $(C_COMMON_H) $(C_TREE_H)
c-simplify.o : c-simplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
$(C_TREE_H) $(C_COMMON_H) diagnostic.h tree-simple.h varray.h flags.h \
langhooks.h toplev.h rtl.h tree-flow.h $(BASIC_BLOCK_H) langhooks-def.h
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-optimize.c,v
retrieving revision 1.1.4.11
diff -d -u -p -r1.1.4.11 tree-optimize.c
--- tree-optimize.c 25 Sep 2002 15:30:25 -0000 1.1.4.11
+++ tree-optimize.c 26 Sep 2002 00:50:10 -0000
@@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA. */
/* This should be eventually be generalized to other languages, but
this would require a shared function-as-trees infrastructure. */
#include "c-common.h"
+#include "c-tree.h"
#include "basic-block.h"
#include "flags.h"
@@ -49,6 +50,9 @@ optimize_function_tree (fndecl)
tree fndecl;
{
tree fnbody;
+ FILE *dump_file;
+ int dump_flags;
+
/* Don't bother doing anything if the program has errors. */
if (errorcount || sorrycount)
@@ -90,6 +94,26 @@ optimize_function_tree (fndecl)
/* Flush out flow graph and SSA data. */
delete_cfg ();
delete_tree_ssa ();
+
+ /* Debugging dump after optimization. */
+ dump_file = dump_begin (TDI_optimized, &dump_flags);
+ if (dump_file)
+ {
+ tree fnbody;
+
+ /* We never get here if the function body is empty,
+ see simplify_function_tree(). */
+ fnbody = COMPOUND_BODY (DECL_SAVED_TREE (fndecl));
+ fprintf (dump_file, "%s()\n", IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+
+ if (dump_flags & TDF_RAW)
+ dump_node (fnbody, TDF_SLIM | dump_flags, dump_file);
+ else
+ print_c_tree (dump_file, fnbody);
+ fprintf (dump_file, "\n");
+
+ dump_end (TDI_optimized, dump_file);
+ }
}