aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2019-07-22 21:41:48 +0000
committerJeff Law <law@gcc.gnu.org>2019-07-22 15:41:48 -0600
commit34e646226fd083e18ae6e07a9ceb18e59bc20077 (patch)
treefabbe280337e8b915b1ca035a02bb3ab20bbe573 /gcc
parent2ac8e32236d0fe6c07545ab0e275403af4a63710 (diff)
downloadgcc-34e646226fd083e18ae6e07a9ceb18e59bc20077.zip
gcc-34e646226fd083e18ae6e07a9ceb18e59bc20077.tar.gz
gcc-34e646226fd083e18ae6e07a9ceb18e59bc20077.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cgraph.c16
-rw-r--r--gcc/cgraph.h9
-rw-r--r--gcc/lto/ChangeLog7
-rw-r--r--gcc/lto/lang.opt3
-rw-r--r--gcc/lto/lto-dump.c52
-rw-r--r--gcc/symtab.c17
7 files changed, 90 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index faa3bde..eda95a0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-02 Giuliano Belinassi <giuliano.belinassi@usp.br>
+
+ * cgraph.c (dump_graphviz): New function.
+ * cgraph.h (dump_graphviz): New function.
+ * symtab.c (dump_graphviz): New function.
+
2019-07-22 Sylvia Taylor <sylvia.taylor@arm.com>
* config/aarch64/aarch64-simd.md
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index a7e3bcf..477db38 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 fa5224f..a7c97de 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 22e7739..c18b2c4 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-22 Giuliano Belinassi <giuliano.belinassi@usp.br>
+
+ * 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 <hubicka@ucw.cz>
* 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 5bacef3..c62dd5a 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 262f9f2..74d99b5 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 b1589ea..63e2820 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -956,6 +956,13 @@ symtab_node::dump (FILE *f)
}
void
+symtab_node::dump_graphviz (FILE *f)
+{
+ if (cgraph_node *cnode = dyn_cast <cgraph_node *> (this))
+ cnode->dump_graphviz (f);
+}
+
+void
symbol_table::dump (FILE *f)
{
symtab_node *node;
@@ -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)
{