[PATCH][tree-ssa] fix tree dumps
Christian Ehrhardt
ehrhardt@mathematik.uni-ulm.de
Wed Apr 14 13:21:00 GMT 2004
Hi,
the following patch (bootstraped and regtested with C and C++ on
sparc-sun-solaris) reenables translation-unit dumping for C. I ran
the C testsuite with -fdump-tree-all which shows no regressions compared
to a run without -fdump-tree-all. A few g++ testcases have remaining
issues when compiled with -fdump-tree-all but these are not regressions.
They just don't show up because noone runs the testsuite with -fdump-tree-all.
regards Christian
2004-04-14 Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de>
* Makefile.in (tree-dump.o): Depend on $(TREE_SIMPLE_H).
* c-decl.c (c_write_global_declarations): Call dump_begin,
dump_node and dump_end.
* c-pretty-print.c (pp_c_type_qualifier_list): Handle ERROR_MARK.
* tree-dump.c: Include tree-simple.h.
(dequeue_and_dump) <CASE_LABEL_EXPR>: Add.
<LABEL_EXPR>: Add.
<GOTO_EXPR>: Add.
<SWITCH_EXPR>: Add.
<STATEMENT_LIST>: Add.
(dump_enabled_p): Handle TDI_all.
* tree-optimize.c (tree_rest_of_compilation): Keep DECL_SAVED_TREE
if a dump is enabled.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.199
diff -u -r1.903.2.199 Makefile.in
--- Makefile.in 6 Apr 2004 02:38:51 -0000 1.903.2.199
+++ Makefile.in 14 Apr 2004 13:17:55 -0000
@@ -1537,7 +1537,7 @@
real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_H)
tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) flags.h langhooks.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
- $(EXPR_H) $(SPLAY_TREE_H) $(TREE_DUMP_H)
+ $(EXPR_H) $(SPLAY_TREE_H) $(TREE_DUMP_H) $(TREE_SIMPLE_H)
tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) $(EXPR_H) flags.h $(PARAMS_H) input.h insn-config.h $(INTEGRATE_H) \
$(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h langhooks.h \
Index: c-decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.90
diff -u -r1.334.2.90 c-decl.c
--- c-decl.c 1 Apr 2004 17:20:47 -0000 1.334.2.90
+++ c-decl.c 14 Apr 2004 13:17:55 -0000
@@ -6722,7 +6722,17 @@
/* Now do the same for the externals scope. */
t = pop_scope ();
if (t)
- c_write_global_declarations_1 (BLOCK_VARS (t));
+ {
+ tree tmp = BLOCK_VARS (t);
+ int flags;
+ FILE * stream = dump_begin (TDI_tu, &flags);
+ if (stream && tmp)
+ {
+ dump_node (tmp, flags & ~TDF_SLIM, stream);
+ dump_end (TDI_tu, stream);
+ }
+ c_write_global_declarations_1 (tmp);
+ }
}
#include "gt-c-decl.h"
Index: c-pretty-print.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.1.4.45
diff -u -r1.1.4.45 c-pretty-print.c
--- c-pretty-print.c 12 Apr 2004 20:10:41 -0000 1.1.4.45
+++ c-pretty-print.c 14 Apr 2004 13:17:55 -0000
@@ -210,6 +210,8 @@
if (!TYPE_P (t))
t = TREE_TYPE (t);
+ if (TREE_CODE (t) == ERROR_MARK)
+ return;
qualifiers = TYPE_QUALS (t);
if (qualifiers & TYPE_QUAL_CONST)
Index: tree-dump.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.6.2.66
diff -u -r1.6.2.66 tree-dump.c
--- tree-dump.c 26 Mar 2004 16:22:27 -0000 1.6.2.66
+++ tree-dump.c 14 Apr 2004 13:17:55 -0000
@@ -29,6 +29,7 @@
#include "toplev.h"
#include "tree-dump.h"
#include "langhooks.h"
+#include "tree-simple.h"
static unsigned int queue (dump_info_p, tree, int);
static void dump_index (dump_info_p, unsigned int);
@@ -574,6 +575,45 @@
dump_child ("init", TREE_OPERAND (t, 3));
break;
+ case CASE_LABEL_EXPR:
+ dump_child ("name", CASE_LABEL (t));
+ if (CASE_LOW (t))
+ {
+ dump_child ("low ", CASE_LOW (t));
+ if (CASE_HIGH (t))
+ {
+ dump_child ("high", CASE_HIGH (t));
+ }
+ }
+ break;
+ case LABEL_EXPR:
+ dump_child ("name", TREE_OPERAND (t,0));
+ break;
+ case GOTO_EXPR:
+ dump_child ("labl", TREE_OPERAND (t, 0));
+ break;
+ case SWITCH_EXPR:
+ dump_child ("cond", TREE_OPERAND (t, 0));
+ dump_child ("body", TREE_OPERAND (t, 1));
+ if (TREE_OPERAND (t, 2))
+ {
+ dump_child ("labl", TREE_OPERAND (t,2));
+ }
+ break;
+
+ case STATEMENT_LIST:
+ {
+ tree_stmt_iterator iter = tsi_start (t);
+ char buffer[32];
+ int i = 0;
+ while (!tsi_end_p (iter))
+ {
+ sprintf (buffer, "%u", i++);
+ dump_child (buffer, tsi_stmt (iter));
+ tsi_next (&iter);
+ }
+ }
+ break;
default:
/* There are no additional fields to print. */
break;
@@ -760,13 +800,28 @@
return stream;
}
-/* Returns nonzero if tree dump PHASE is enabled. */
+/* Returns nonzero if tree dump PHASE is enabled. If PHASE is
+ TDI_all, return nonzero if any dump is enabled. */
int
dump_enabled_p (enum tree_dump_index phase)
{
- struct dump_file_info *dfi = get_dump_file_info (phase);
- return dfi->state;
+ if (phase == TDI_all)
+ {
+ size_t i;
+ for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
+ if (dump_files[i].state)
+ return 1;
+ for (i = 0; i < extra_dump_files_in_use; i++)
+ if (extra_dump_files[i].state)
+ return 1;
+ return 0;
+ }
+ else
+ {
+ struct dump_file_info *dfi = get_dump_file_info (phase);
+ return dfi->state;
+ }
}
/* Returns the switch name of PHASE. */
Index: tree-optimize.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.139
diff -u -r1.1.4.139 tree-optimize.c
--- tree-optimize.c 12 Apr 2004 23:45:38 -0000 1.1.4.139
+++ tree-optimize.c 14 Apr 2004 13:17:55 -0000
@@ -610,7 +610,7 @@
cgraph_remove_node (saved_node);
}
}
- else
+ else if (!dump_enabled_p (TDI_all))
DECL_SAVED_TREE (fndecl) = NULL;
cfun = 0;
More information about the Gcc-patches
mailing list