public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] give graphs from graph dump a name
@ 2013-02-15  0:01 Steven Bosscher
  2013-02-15  9:07 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Bosscher @ 2013-02-15  0:01 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Biener

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);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] give graphs from graph dump a name
  2013-02-15  0:01 [patch] give graphs from graph dump a name Steven Bosscher
@ 2013-02-15  9:07 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2013-02-15  9:07 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

On Fri, Feb 15, 2013 at 1:00 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> 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?

Ok.

Thanks,
Richard.

> 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);
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-15  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15  0:01 [patch] give graphs from graph dump a name Steven Bosscher
2013-02-15  9:07 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).