This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[incremental] Patch: FYI: re-enable translation unit dump
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 02 Apr 2008 10:37:00 -0600
- Subject: [incremental] Patch: FYI: re-enable translation unit dump
- Reply-to: tromey at redhat dot com
I'm checking this in on the incremental-compiler branch.
I had disabled -fdump-translation-unit when reworking scope popping to
use a VEC. This re-enables it by adding a new dump function.
Tom
ChangeLog:
2008-04-02 Tom Tromey <tromey@redhat.com>
* c-decl.c (c_clear_binding_stack): Use dump_vec.
* tree-pass.h (dump_vec): Declare.
* tree-dump.c (dump_vec): New function.
Index: tree-dump.c
===================================================================
--- tree-dump.c (revision 132956)
+++ tree-dump.c (working copy)
@@ -1,5 +1,5 @@
/* Tree-dumping functionality for intermediate representation.
- Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>
@@ -776,6 +776,48 @@
}
splay_tree_delete (di.nodes);
}
+
+
+/* Like dump_node, but dump a VEC holding nodes, rather than a list of
+ nodes. */
+
+void
+dump_vec (VEC (tree, gc) *nodes, int flags, FILE *stream)
+{
+ struct dump_info di;
+ dump_queue_p dq;
+ dump_queue_p next_dq;
+ tree node;
+ int ix;
+
+ /* Initialize the dump-information structure. */
+ di.stream = stream;
+ di.index = 0;
+ di.column = 0;
+ di.queue = 0;
+ di.queue_end = 0;
+ di.free_list = 0;
+ di.flags = flags;
+ di.node = NULL;
+ di.nodes = splay_tree_new (splay_tree_compare_pointers, 0,
+ (splay_tree_delete_value_fn) &free);
+
+ /* Queue up all nodes in the vector. */
+ for (ix = 0; VEC_iterate (tree, nodes, ix, node); ++ix)
+ queue (&di, node, DUMP_NONE);
+
+ /* Until the queue is empty, keep dumping nodes. */
+ while (di.queue)
+ dequeue_and_dump (&di);
+
+ /* Now, clean up. */
+ for (dq = di.free_list; dq; dq = next_dq)
+ {
+ next_dq = dq->next;
+ free (dq);
+ }
+ splay_tree_delete (di.nodes);
+}
/* Table of tree dump switches. This must be consistent with the
Index: tree-pass.h
===================================================================
--- tree-pass.h (revision 133149)
+++ tree-pass.h (working copy)
@@ -77,6 +77,7 @@
extern FILE *dump_begin (enum tree_dump_index, int *);
extern void dump_end (enum tree_dump_index, FILE *);
extern void dump_node (const_tree, int, FILE *);
+extern void dump_vec (VEC (tree, gc) *, int, FILE *);
extern int dump_switch_p (const char *);
extern const char *dump_flag_name (enum tree_dump_index);
Index: c-decl.c
===================================================================
--- c-decl.c (revision 133179)
+++ c-decl.c (working copy)
@@ -8708,6 +8708,9 @@
void
c_clear_binding_stack (void)
{
+ int flags;
+ FILE *stream;
+
/* We don't want to do this if generating a PCH. */
if (pch_file)
return;
@@ -8719,18 +8722,12 @@
external_scope = 0;
gcc_assert (!current_scope);
- /* FIXME: re-enable this using all_global_decls. */
-/* if (ext_block) */
-/* { */
-/* tree tmp = BLOCK_VARS (ext_block); */
-/* int flags; */
-/* FILE * stream = dump_begin (TDI_tu, &flags); */
-/* if (stream && tmp) */
-/* { */
-/* dump_node (tmp, flags & ~TDF_SLIM, stream); */
-/* dump_end (TDI_tu, stream); */
-/* } */
-/* } */
+ stream = dump_begin (TDI_tu, &flags);
+ if (stream)
+ {
+ dump_vec (all_global_decls, flags & ~TDF_SLIM, stream);
+ dump_end (TDI_tu, stream);
+ }
}
/* This maps trees to their canonical (smashed) variants. This must