From: Giuliano Belinassi Date: Mon, 22 Jul 2019 21:41:48 +0000 (+0000) Subject: cgraph.c (dump_graphviz): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=34e646226fd083e18ae6e07a9ceb18e59bc20077;p=gcc.git cgraph.c (dump_graphviz): New function. * cgraph.c (dump_graphviz): New function. * cgraph.h (dump_graphviz): New function. * symtab.c (dump_graphviz): New function. * lang.opt (flag_dump_callgraph): New flag. * lto-dump.c (dump_symtab_graphviz): New function. (dump_tool_help): New option. (lto_main): Handle graphviz dumping. From-SVN: r273708 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index faa3bde2295..eda95a0ac20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-07-02 Giuliano Belinassi + + * cgraph.c (dump_graphviz): New function. + * cgraph.h (dump_graphviz): New function. + * symtab.c (dump_graphviz): New function. + 2019-07-22 Sylvia Taylor * config/aarch64/aarch64-simd.md diff --git a/gcc/cgraph.c b/gcc/cgraph.c index a7e3bcf2132..477db385c96 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -2204,6 +2204,22 @@ cgraph_node::dump (FILE *f) } } +/* Dump call graph node to file F in graphviz format. */ + +void +cgraph_node::dump_graphviz (FILE *f) +{ + cgraph_edge *edge; + + for (edge = callees; edge; edge = edge->next_callee) + { + cgraph_node *callee = edge->callee; + + fprintf (f, "\t\"%s\" -> \"%s\"\n", name (), callee->name ()); + } +} + + /* Dump call graph node NODE to stderr. */ DEBUG_FUNCTION void diff --git a/gcc/cgraph.h b/gcc/cgraph.h index fa5224fb3a5..a7c97de9ff7 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -135,6 +135,9 @@ public: /* Dump symtab node to F. */ void dump (FILE *f); + /* Dump symtab callgraph in graphviz format. */ + void dump_graphviz (FILE *f); + /* Dump symtab node to stderr. */ void DEBUG_FUNCTION debug (void); @@ -1106,6 +1109,9 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node /* Dump call graph node to file F. */ void dump (FILE *f); + /* Dump call graph node to file F. */ + void dump_graphviz (FILE *f); + /* Dump call graph node to stderr. */ void DEBUG_FUNCTION debug (void); @@ -2282,6 +2288,9 @@ public: /* Dump symbol table to F. */ void dump (FILE *f); + /* Dump symbol table to F in graphviz format. */ + void dump_graphviz (FILE *f); + /* Dump symbol table to stderr. */ void DEBUG_FUNCTION debug (void); diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 22e7739d3d7..c18b2c47cc1 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,10 @@ +2019-07-22 Giuliano Belinassi + + * lang.opt (flag_dump_callgraph): New flag. + * lto-dump.c (dump_symtab_graphviz): New function. + (dump_tool_help): New option. + (lto_main): Handle graphviz dumping. + 2019-07-18 Jan Hubicka * lto-common.c (gimple_register_canonical_type_1): Do not look for diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt index 5bacef349e3..c62dd5aac08 100644 --- a/gcc/lto/lang.opt +++ b/gcc/lto/lang.opt @@ -127,6 +127,9 @@ help LTODump Var(flag_lto_dump_tool_help) Dump the dump tool command line options. +callgraph +LTODump Var(flag_dump_callgraph) +Dump the symtab callgraph. fresolution= LTO Joined diff --git a/gcc/lto/lto-dump.c b/gcc/lto/lto-dump.c index 262f9f24d85..74d99b5f0f4 100644 --- a/gcc/lto/lto-dump.c +++ b/gcc/lto/lto-dump.c @@ -215,6 +215,12 @@ void dump_list_variables (void) } } +/* Dump symbol table in graphviz format. */ +void dump_symtab_graphviz (void) +{ + symtab->dump_graphviz (stdout); +} + /* Dump symbol list. */ void dump_list (void) @@ -269,26 +275,27 @@ void dump_body () /* List of command line options for dumping. */ void dump_tool_help () { - printf ("Usage: lto-dump [OPTION]... SUB_COMMAND [OPTION]...\n\n"); - printf ("LTO dump tool command line options.\n\n"); - printf (" -list [options] Dump the symbol list.\n"); - printf (" -demangle Dump the demangled output.\n"); - printf (" -defined-only Dump only the defined symbols.\n"); - printf (" -print-value Dump initial values of the " - "variables.\n"); - printf (" -name-sort Sort the symbols alphabetically.\n"); - printf (" -size-sort Sort the symbols according to size.\n"); - printf (" -reverse-sort Dump the symbols in reverse order.\n"); - printf (" -symbol= Dump the details of specific symbol.\n"); - printf (" -objects Dump the details of LTO objects.\n"); - printf (" -type-stats Dump statistics of tree types.\n"); - printf (" -tree-stats Dump statistics of trees.\n"); - printf (" -gimple-stats Dump statistics of gimple " - "statements.\n"); - printf (" -dump-body= Dump the specific gimple body.\n"); - printf (" -dump-level= Deciding the optimization level " - "of body.\n"); - printf (" -help Display the dump tool help.\n"); + const char *msg = + "Usage: lto-dump [OPTION]... SUB_COMMAND [OPTION]...\n\n" + "LTO dump tool command line options.\n\n" + " -list [options] Dump the symbol list.\n" + " -demangle Dump the demangled output.\n" + " -defined-only Dump only the defined symbols.\n" + " -print-value Dump initial values of the variables.\n" + " -name-sort Sort the symbols alphabetically.\n" + " -size-sort Sort the symbols according to size.\n" + " -reverse-sort Dump the symbols in reverse order.\n" + " -symbol= Dump the details of specific symbol.\n" + " -objects Dump the details of LTO objects.\n" + " -callgraph Dump the callgraph in graphviz format.\n" + " -type-stats Dump statistics of tree types.\n" + " -tree-stats Dump statistics of trees.\n" + " -gimple-stats Dump statistics of gimple statements.\n" + " -dump-body= Dump the specific gimple body.\n" + " -dump-level= Deciding the optimization level of body.\n" + " -help Display the dump tool help.\n"; + + fputs (msg, stdout); return; } @@ -362,4 +369,9 @@ lto_main (void) dump_body (); return; } + else if (flag_dump_callgraph) + { + dump_symtab_graphviz (); + return; + } } diff --git a/gcc/symtab.c b/gcc/symtab.c index b1589ea8a40..63e2820eb93 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -955,6 +955,13 @@ symtab_node::dump (FILE *f) vnode->dump (f); } +void +symtab_node::dump_graphviz (FILE *f) +{ + if (cgraph_node *cnode = dyn_cast (this)) + cnode->dump_graphviz (f); +} + void symbol_table::dump (FILE *f) { @@ -964,6 +971,16 @@ symbol_table::dump (FILE *f) node->dump (f); } +void +symbol_table::dump_graphviz (FILE *f) +{ + symtab_node *node; + fprintf (f, "digraph symtab {\n"); + FOR_EACH_SYMBOL (node) + node->dump_graphviz (f); + fprintf (f, "}\n"); +} + DEBUG_FUNCTION void symbol_table::debug (void) {