public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Simple change in dot dumper -- Display profile count and branch probability
@ 2013-04-21 20:36 Xinliang David Li
  2013-04-21 20:54 ` Steven Bosscher
  0 siblings, 1 reply; 6+ messages in thread
From: Xinliang David Li @ 2013-04-21 20:36 UTC (permalink / raw)
  To: GCC Patches

Hi, the graph dump file currently does not show any profile
information. The following simple patch fixed that.  Ok for trunk?

thanks,

David

2013-04-20  Xinliang David Li  <davidxl@google.com>

        * graph.c (draw_cfg_node): Add count and frequency info.
        (draw_cfg_node_succ_edges): Add branch probility as label.

Index: graph.c
===================================================================
--- graph.c     (revision 198108)
+++ graph.c     (working copy)
@@ -110,6 +110,9 @@ draw_cfg_node (pretty_printer *pp, int f
   else
     {
       pp_character (pp, '{');
+      if (bb->count)
+       pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
+      pp_printf (pp, " FREQ:%i |", bb->frequency);
       pp_write_text_to_stream (pp);
       dump_bb_for_graph (pp, bb);
       pp_character (pp, '}');
@@ -155,11 +158,12 @@ draw_cfg_node_succ_edges (pretty_printer

       pp_printf (pp,
                 "\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n "
-                "[style=%s,color=%s,weight=%d,constraint=%s];\n",
+                "[style=%s,color=%s,weight=%d,constraint=%s,
label=\"[%i%%]\"];\n",
                 funcdef_no, e->src->index,
                 funcdef_no, e->dest->index,
                 style, color, weight,
-                (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true");
+                (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true",
+                e->probability * 100 / REG_BR_PROB_BASE);
     }
   pp_flush (pp);
 }

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

* Re: Simple change in dot dumper -- Display profile count and branch probability
  2013-04-21 20:36 Simple change in dot dumper -- Display profile count and branch probability Xinliang David Li
@ 2013-04-21 20:54 ` Steven Bosscher
  2013-04-21 21:17   ` Xinliang David Li
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Bosscher @ 2013-04-21 20:54 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: GCC Patches

On Sun, Apr 21, 2013 at 12:47 AM, Xinliang David Li wrote:
> Index: graph.c
> ===================================================================
> --- graph.c     (revision 198108)
> +++ graph.c     (working copy)
> @@ -110,6 +110,9 @@ draw_cfg_node (pretty_printer *pp, int f
>    else
>      {
>        pp_character (pp, '{');
> +      if (bb->count)
> +       pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
> +      pp_printf (pp, " FREQ:%i |", bb->frequency);
>        pp_write_text_to_stream (pp);
>        dump_bb_for_graph (pp, bb);
>        pp_character (pp, '}');

This doesn't belong here, please put it in cfghooks.c:dump_bb_for_graph.

Otherwise, looks good me.

Ciao!
Steven

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

* Re: Simple change in dot dumper -- Display profile count and branch probability
  2013-04-21 20:54 ` Steven Bosscher
@ 2013-04-21 21:17   ` Xinliang David Li
  2013-04-22 20:36     ` Diego Novillo
  0 siblings, 1 reply; 6+ messages in thread
From: Xinliang David Li @ 2013-04-21 21:17 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Patches

Thanks.   The patch is revised.

David

2013-04-20  Xinliang David Li  <davidxl@google.com>

        * graph.c (draw_cfg_node_succ_edges): Add branch probility as label.
        * cfghhooks.c (dump_bb_for_graph): Dump profile count and frquency.
        * Makefile.in: New dependency.

Index: cfghooks.c
===================================================================
--- cfghooks.c  (revision 198108)
+++ cfghooks.c  (working copy)
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.
 #include "timevar.h"
 #include "diagnostic-core.h"
 #include "cfgloop.h"
+#include "pretty-print.h"

 /* A pointer to one of the hooks containers.  */
 static struct cfg_hooks *cfg_hooks;
@@ -308,6 +309,10 @@ dump_bb_for_graph (pretty_printer *pp, b
   if (!cfg_hooks->dump_bb_for_graph)
     internal_error ("%s does not support dump_bb_for_graph",
                    cfg_hooks->name);
+  if (bb->count)
+    pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
+  pp_printf (pp, " FREQ:%i |", bb->frequency);
+  pp_write_text_to_stream (pp);
   cfg_hooks->dump_bb_for_graph (pp, bb);
 }

Index: graph.c
===================================================================
--- graph.c     (revision 198108)
+++ graph.c     (working copy)
@@ -155,11 +155,12 @@ draw_cfg_node_succ_edges (pretty_printer

       pp_printf (pp,
                 "\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n "
-                "[style=%s,color=%s,weight=%d,constraint=%s];\n",
+                "[style=%s,color=%s,weight=%d,constraint=%s,
label=\"[%i%%]\"];\n",
                 funcdef_no, e->src->index,
                 funcdef_no, e->dest->index,
                 style, color, weight,
-                (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true");
+                (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true",
+                e->probability * 100 / REG_BR_PROB_BASE);
     }
   pp_flush (pp);
 }
Index: Makefile.in
===================================================================
--- Makefile.in (revision 198108)
+++ Makefile.in (working copy)
@@ -3123,7 +3123,7 @@ cfg.o : cfg.c $(CONFIG_H) $(SYSTEM_H) co
    $(GGC_H) $(OBSTACK_H) alloc-pool.h $(HASH_TABLE_H) $(CFGLOOP_H) $(TREE_H) \
    $(BASIC_BLOCK_H)
 cfghooks.o: cfghooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
-   $(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TIMEVAR_H) toplev.h
$(DIAGNOSTIC_CORE_H) $(CFGLOOP_H)
+   $(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TIMEVAR_H) toplev.h
$(DIAGNOSTIC_CORE_H) $(CFGLOOP_H) $(PRETTY_PRINT_H)
 cfgexpand.o : cfgexpand.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(FUNCTION_H) $(TM_H) \
    coretypes.h $(EXCEPT_H) langhooks.h $(TREE_PASS_H) $(RTL_H) \

On Sat, Apr 20, 2013 at 4:02 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Sun, Apr 21, 2013 at 12:47 AM, Xinliang David Li wrote:
>> Index: graph.c
>> ===================================================================
>> --- graph.c     (revision 198108)
>> +++ graph.c     (working copy)
>> @@ -110,6 +110,9 @@ draw_cfg_node (pretty_printer *pp, int f
>>    else
>>      {
>>        pp_character (pp, '{');
>> +      if (bb->count)
>> +       pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
>> +      pp_printf (pp, " FREQ:%i |", bb->frequency);
>>        pp_write_text_to_stream (pp);
>>        dump_bb_for_graph (pp, bb);
>>        pp_character (pp, '}');
>
> This doesn't belong here, please put it in cfghooks.c:dump_bb_for_graph.
>
> Otherwise, looks good me.
>
> Ciao!
> Steven

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

* Re: Simple change in dot dumper -- Display profile count and branch probability
  2013-04-21 21:17   ` Xinliang David Li
@ 2013-04-22 20:36     ` Diego Novillo
  2013-04-23  9:06       ` Xinliang David Li
  0 siblings, 1 reply; 6+ messages in thread
From: Diego Novillo @ 2013-04-22 20:36 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: Steven Bosscher, GCC Patches

On 2013-04-21 02:37 , Xinliang David Li wrote:
>          * graph.c (draw_cfg_node_succ_edges): Add branch probility as label.
>          * cfghhooks.c (dump_bb_for_graph): Dump profile count and frquency.
>          * Makefile.in: New dependency.

Looks OK.


Diego.

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

* Re: Simple change in dot dumper -- Display profile count and branch probability
  2013-04-22 20:36     ` Diego Novillo
@ 2013-04-23  9:06       ` Xinliang David Li
  2013-04-23 10:15         ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Xinliang David Li @ 2013-04-23  9:06 UTC (permalink / raw)
  To: Diego Novillo; +Cc: Steven Bosscher, GCC Patches

Hi, this is a follow up simple patch to support 'slim' graph dump:
when -slim option is specified (e.g,
-fdump-tree-optimized-graph-slim), do not dump the boby.

2013-04-22  Xinliang David Li  <davidxl@google.com>

        * cfghhooks.c (dump_bb_for_graph): Support 'slim' graph dump.


Index: cfghooks.c
===================================================================
--- cfghooks.c  (revision 198165)
+++ cfghooks.c  (working copy)
@@ -313,7 +313,8 @@ dump_bb_for_graph (pretty_printer *pp, b
     pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
   pp_printf (pp, " FREQ:%i |", bb->frequency);
   pp_write_text_to_stream (pp);
-  cfg_hooks->dump_bb_for_graph (pp, bb);
+  if (!(dump_flags & TDF_SLIM))
+    cfg_hooks->dump_bb_for_graph (pp, bb);
 }

 /* Dump the complete CFG to FILE.  FLAGS are the TDF_* flags in dumpfile.h.  */


Ok for trunk?

thanks,

David

On Mon, Apr 22, 2013 at 12:23 PM, Diego Novillo <dnovillo@google.com> wrote:
> On 2013-04-21 02:37 , Xinliang David Li wrote:
>>
>>          * graph.c (draw_cfg_node_succ_edges): Add branch probility as
>> label.
>>          * cfghhooks.c (dump_bb_for_graph): Dump profile count and
>> frquency.
>>          * Makefile.in: New dependency.
>
>
> Looks OK.
>
>
> Diego.

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

* Re: Simple change in dot dumper -- Display profile count and branch probability
  2013-04-23  9:06       ` Xinliang David Li
@ 2013-04-23 10:15         ` Richard Biener
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Biener @ 2013-04-23 10:15 UTC (permalink / raw)
  To: Xinliang David Li; +Cc: Diego Novillo, Steven Bosscher, GCC Patches

On Tue, Apr 23, 2013 at 7:40 AM, Xinliang David Li <davidxl@google.com> wrote:
> Hi, this is a follow up simple patch to support 'slim' graph dump:
> when -slim option is specified (e.g,
> -fdump-tree-optimized-graph-slim), do not dump the boby.

Ok.

Thanks,
Richard.

> 2013-04-22  Xinliang David Li  <davidxl@google.com>
>
>         * cfghhooks.c (dump_bb_for_graph): Support 'slim' graph dump.
>
>
> Index: cfghooks.c
> ===================================================================
> --- cfghooks.c  (revision 198165)
> +++ cfghooks.c  (working copy)
> @@ -313,7 +313,8 @@ dump_bb_for_graph (pretty_printer *pp, b
>      pp_printf (pp, "COUNT:" HOST_WIDEST_INT_PRINT_DEC, bb->count);
>    pp_printf (pp, " FREQ:%i |", bb->frequency);
>    pp_write_text_to_stream (pp);
> -  cfg_hooks->dump_bb_for_graph (pp, bb);
> +  if (!(dump_flags & TDF_SLIM))
> +    cfg_hooks->dump_bb_for_graph (pp, bb);
>  }
>
>  /* Dump the complete CFG to FILE.  FLAGS are the TDF_* flags in dumpfile.h.  */
>
>
> Ok for trunk?
>
> thanks,
>
> David
>
> On Mon, Apr 22, 2013 at 12:23 PM, Diego Novillo <dnovillo@google.com> wrote:
>> On 2013-04-21 02:37 , Xinliang David Li wrote:
>>>
>>>          * graph.c (draw_cfg_node_succ_edges): Add branch probility as
>>> label.
>>>          * cfghhooks.c (dump_bb_for_graph): Dump profile count and
>>> frquency.
>>>          * Makefile.in: New dependency.
>>
>>
>> Looks OK.
>>
>>
>> Diego.

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

end of thread, other threads:[~2013-04-23  8:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 20:36 Simple change in dot dumper -- Display profile count and branch probability Xinliang David Li
2013-04-21 20:54 ` Steven Bosscher
2013-04-21 21:17   ` Xinliang David Li
2013-04-22 20:36     ` Diego Novillo
2013-04-23  9:06       ` Xinliang David Li
2013-04-23 10:15         ` 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).