From 3e894af1569a84c5bb6eb730266248e6a4cae2de Mon Sep 17 00:00:00 2001 From: Kenneth Zadeck Date: Fri, 16 May 2008 13:34:34 +0000 Subject: [PATCH] invoke.text (-fdump-tree-*-verbose): New option. 2008-05-16 Kenneth Zadeck * doc/invoke.text (-fdump-tree-*-verbose): New option. * tree-dump.c (dump_options): New verbose option. * tree-pretty-print.c (dump_phi_nodes, dump_generic_bb_buff): Add verbose dump. * tree-pass.h (TDF_VERBOSE): New dump flag. * print-tree.c (print_node): Added code to be able to print PHI_NODES. (tree-flow.h): Added include. Makefile.in (print-tree.o): Added TREE_FLOW_H. From-SVN: r135417 --- gcc/ChangeLog | 12 ++++++++++++ gcc/Makefile.in | 2 +- gcc/doc/invoke.texi | 5 ++++- gcc/print-tree.c | 41 ++++++++++++++++++++++++++--------------- gcc/tree-cfg.c | 7 +++++++ gcc/tree-dump.c | 3 ++- gcc/tree-pass.h | 2 ++ gcc/tree-pretty-print.c | 12 ++++++++---- 8 files changed, 62 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5cd0d1fa52e..1c2ac87f620 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2008-05-16 Kenneth Zadeck + + * doc/invoke.text (-fdump-tree-*-verbose): New option. + * tree-dump.c (dump_options): New verbose option. + * tree-pretty-print.c (dump_phi_nodes, dump_generic_bb_buff): + Add verbose dump. + * tree-pass.h (TDF_VERBOSE): New dump flag. + * print-tree.c (print_node): Added code to be able to print + PHI_NODES. + (tree-flow.h): Added include. + Makefile.in (print-tree.o): Added TREE_FLOW_H. + 2008-05-16 Bernd Schmidt * config/bfin/bfin.c (bfin_discover_loops): Delete empty loops. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 99d16a21b9b..56d2aed7840 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1986,7 +1986,7 @@ tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ debug.h $(DIAGNOSTIC_H) $(TREE_FLOW_H) tree-iterator.h tree-mudflap.h \ ipa-prop.h value-prof.h $(TARGET_H) $(INTEGRATE_H) print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ - $(GGC_H) langhooks.h $(REAL_H) tree-iterator.h fixed-value.h + $(GGC_H) langhooks.h $(REAL_H) tree-iterator.h fixed-value.h $(TREE_FLOW_H) stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(PARAMS_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) $(RTL_H) \ $(GGC_H) $(TM_P_H) $(TARGET_H) langhooks.h $(REGS_H) gt-stor-layout.h \ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index de658f42aa7..e515a0f191b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4771,8 +4771,11 @@ Enable showing virtual operands for every statement. Enable showing line numbers for statements. @item uid Enable showing the unique ID (@code{DECL_UID}) for each variable. +@item verbose +Enable showing the tree dump for each statement. @item all -Turn on all options, except @option{raw}, @option{slim} and @option{lineno}. +Turn on all options, except @option{raw}, @option{slim}, @option{verbose} +and @option{lineno}. @end table The following tree dumps are possible: diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 4745491de56..3b34f89d41c 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "ggc.h" #include "langhooks.h" #include "tree-iterator.h" +#include "tree-flow.h" /* Define the hash table of nodes already seen. Such nodes are not repeated; brief cross-references are used. */ @@ -221,21 +222,25 @@ print_node (FILE *file, const char *prefix, tree node, int indent) return; } - hash = ((unsigned long) node) % HASH_SIZE; - - /* If node is in the table, just mention its address. */ - for (b = table[hash]; b; b = b->next) - if (b->node == node) - { - print_node_brief (file, prefix, node, indent); - return; - } - - /* Add this node to the table. */ - b = XNEW (struct bucket); - b->node = node; - b->next = table[hash]; - table[hash] = b; + /* Allow this function to be called if the table is not there. */ + if (table) + { + hash = ((unsigned long) node) % HASH_SIZE; + + /* If node is in the table, just mention its address. */ + for (b = table[hash]; b; b = b->next) + if (b->node == node) + { + print_node_brief (file, prefix, node, indent); + return; + } + + /* Add this node to the table. */ + b = XNEW (struct bucket); + b->node = node; + b->next = table[hash]; + table[hash] = b; + } /* Indent to the specified column, since this is the long form. */ indent_to (file, indent); @@ -906,6 +911,12 @@ print_node (FILE *file, const char *prefix, tree node, int indent) } break; + case PHI_NODE: + print_node (file, "result", PHI_RESULT (node), indent + 4); + for (i = 0; i < PHI_NUM_ARGS (node); i++) + print_node (file, "arg", PHI_ARG_DEF (node, i), indent + 4); + break; + case OMP_CLAUSE: { int i; diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index ed5282691da..2de19c4b7a3 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6179,12 +6179,17 @@ dump_function_to_file (tree fn, FILE *file, int flags) print_generic_expr (file, TREE_TYPE (arg), dump_flags); fprintf (file, " "); print_generic_expr (file, arg, dump_flags); + if (flags & TDF_VERBOSE) + print_node (file, "", arg, 4); if (TREE_CHAIN (arg)) fprintf (file, ", "); arg = TREE_CHAIN (arg); } fprintf (file, ")\n"); + if (flags & TDF_VERBOSE) + print_node (file, "", fn, 2); + dsf = DECL_STRUCT_FUNCTION (fn); if (dsf && (flags & TDF_DETAILS)) dump_eh_tree (file, dsf); @@ -6210,6 +6215,8 @@ dump_function_to_file (tree fn, FILE *file, int flags) var = TREE_VALUE (vars); print_generic_decl (file, var, flags); + if (flags & TDF_VERBOSE) + print_node (file, "", var, 4); fprintf (file, "\n"); any_var = true; diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index 29bcbb416f2..8e911ab93ea 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -822,8 +822,9 @@ static const struct dump_option_value_info dump_options[] = {"uid", TDF_UID}, {"stmtaddr", TDF_STMTADDR}, {"memsyms", TDF_MEMSYMS}, + {"verbose", TDF_VERBOSE}, {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA - | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC)}, + | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE)}, {NULL, 0} }; diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 8ec46e87939..916df71ac6b 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -70,6 +70,8 @@ enum tree_dump_index #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic message. */ +#define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree + dumper to print stmts. */ extern char *get_dump_file_name (enum tree_dump_index); extern int dump_enabled_p (enum tree_dump_index); diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 69e5e73bda8..811c195e126 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -436,10 +436,10 @@ dump_symbols (pretty_printer *buffer, bitmap syms, int flags) } -/* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent. - FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h). - If IS_STMT is true, the object printed is considered to be a statement - and it is terminated by ';' if appropriate. */ +/* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of + indent. FLAGS specifies details to show in the dump (see TDF_* in + tree-pass.h). If IS_STMT is true, the object printed is considered + to be a statement and it is terminated by ';' if appropriate. */ int dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, @@ -3052,6 +3052,8 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) pp_string (buffer, "# "); dump_generic_node (buffer, phi, indent, flags, false); pp_newline (buffer); + if (flags & TDF_VERBOSE) + print_node (buffer->buffer->stream, "", phi, indent); } } } @@ -3170,6 +3172,8 @@ dump_generic_bb_buff (pretty_printer *buffer, basic_block bb, dump_generic_node (buffer, stmt, curr_indent, flags, true); pp_newline (buffer); dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt); + if (flags & TDF_VERBOSE) + print_node (buffer->buffer->stream, "", stmt, curr_indent); } dump_implicit_edges (buffer, bb, indent, flags); -- 2.30.2