Hello, A user sent me a request to give names to the digraph in a graph dump. This name can be used as a key for the dump, for a tool that can generate graph metrics to see GCC transforms code as it passes through the pipeline. Another user requested the same thing for a hacked xdot that can plot multiple digraphs.
The dumpfile base name seemed like a good name for the digraph. This patch prints it as the digraph label. Bootstrapped&tested on powerpc64-unknown-linux-gnu. Tested the graph dump by dumping the .pre dump for my cc1-i files and plotting them (*). OK for trunk? Ciao! Steven (*) note to self: manually tail-merge mark_stmt_necessary calls in mark_stmt_if_obviously_necessary, or make mark_stmt_necessary non-inline -- the graphs nicely show terrible code duplication :-) * graph.c (start_graph_dump): Print dumpfile base name as digraph label. (clean_graph_dump_file): Pass base to start_graph_dump. Index: graph.c =================================================================== --- graph.c (revision 196059) +++ graph.c (working copy) @@ -308,11 +308,16 @@ print_graph_cfg (const char *base, struct function /* Start the dump of a graph. */ static void -start_graph_dump (FILE *fp) +start_graph_dump (FILE *fp, const char *base) { - fputs ("digraph \"\" {\n" - "overlap=false;\n", - fp); + pretty_printer *pp = init_graph_slim_pretty_print (fp); + pp_string (pp, "digraph \""); + pp_write_text_to_stream (pp); + pp_string (pp, base); + pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/false); + pp_string (pp, "\" {\n"); + pp_string (pp, "overlap=false;\n"); + pp_flush (pp); } /* End the dump of a graph. */ @@ -327,7 +332,7 @@ void clean_graph_dump_file (const char *base) { FILE *fp = open_graph_file (base, "w"); - start_graph_dump (fp); + start_graph_dump (fp, base); fclose (fp); }