This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Re-implement LTO streamer (3/5)
- From: Diego Novillo <dnovillo at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Jul 2009 12:11:16 -0400
- Subject: [lto] Re-implement LTO streamer (3/5)
Part 3 of http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00279.html.
I found this useful while debugging problems with the new
streamer. It detects cycles in TREE_CHAINs without blindly
following it.
I will commit this to mainline as well.
Diego.
* tree-pretty-print.c (debug_tree_chain): Handle cycles.
Index: tree-pretty-print.c
===================================================================
--- tree-pretty-print.c (revision 149023)
+++ tree-pretty-print.c (working copy)
@@ -99,13 +99,24 @@ debug_generic_stmt (tree t)
void
debug_tree_chain (tree t)
{
+ struct pointer_set_t *seen = pointer_set_create ();
+
while (t)
- {
- print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
- fprintf(stderr, " ");
- t = TREE_CHAIN (t);
- }
+ {
+ print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
+ fprintf (stderr, " ");
+ t = TREE_CHAIN (t);
+ if (pointer_set_insert (seen, t))
+ {
+ fprintf (stderr, "... [cycled back to ");
+ print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
+ fprintf (stderr, "]");
+ break;
+ }
+ }
fprintf (stderr, "\n");
+
+ pointer_set_destroy (seen);
}
/* Prints declaration DECL to the FILE with details specified by FLAGS. */