diff options
Diffstat (limited to 'gcc/graph.c')
-rw-r--r-- | gcc/graph.c | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/gcc/graph.c b/gcc/graph.c index c0a9af8..7fdd41c 100644 --- a/gcc/graph.c +++ b/gcc/graph.c @@ -24,15 +24,10 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "diagnostic-core.h" /* for fatal_error */ -#include "sbitmap.h" #include "basic-block.h" -#include "rtl.h" -#include "tree.h" -#include "gimple.h" #include "graph.h" #include "dumpfile.h" #include "pretty-print.h" -#include "gimple-pretty-print.h" /* DOT files with the .dot extension are recognized as document templates by a well-known piece of word processing software out of Redmond, WA. @@ -80,10 +75,10 @@ init_graph_slim_pretty_print (FILE *fp) return &graph_slim_pp; } -/* Draw a basic block BB belonging to the function with FNDECL_UID +/* Draw a basic block BB belonging to the function with FUNCDEF_NO as its unique number. */ static void -draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb) +draw_cfg_node (pretty_printer *pp, int funcdef_no, basic_block bb) { const char *shape; const char *fillcolor; @@ -105,7 +100,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb) pp_printf (pp, "\tfn_%d_basic_block_%d " "[shape=%s,style=filled,fillcolor=%s,label=\"", - fndecl_uid, bb->index, shape, fillcolor); + funcdef_no, bb->index, shape, fillcolor); if (bb->index == ENTRY_BLOCK) pp_string (pp, "ENTRY"); @@ -115,28 +110,7 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb) { pp_character (pp, '{'); pp_write_text_to_stream (pp); - - /* This would be easier if there'd be an IR independent iterator... */ - if (current_ir_type () == IR_GIMPLE) - gimple_dump_bb_for_graph (pp, bb); - else - { - rtx insn; - bool first = true; - - /* TODO: inter-bb stuff. */ - FOR_BB_INSNS (bb, insn) - { - if (! first) - { - pp_character (pp, '|'); - pp_write_text_to_stream (pp); - } - first = false; - print_insn_with_notes (pp, insn); - pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); - } - } + dump_bb_for_graph (pp, bb); pp_character (pp, '}'); } @@ -145,9 +119,9 @@ draw_cfg_node (pretty_printer *pp, int fndecl_uid, basic_block bb) } /* Draw all successor edges of a basic block BB belonging to the function - with FNDECL_UID as its unique number. */ + with FUNCDEF_NO as its unique number. */ static void -draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb) +draw_cfg_node_succ_edges (pretty_printer *pp, int funcdef_no, basic_block bb) { edge e; edge_iterator ei; @@ -181,8 +155,8 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb) pp_printf (pp, "\tfn_%d_basic_block_%d:s -> fn_%d_basic_block_%d:n " "[style=%s,color=%s,weight=%d,constraint=%s];\n", - fndecl_uid, e->src->index, - fndecl_uid, e->dest->index, + funcdef_no, e->src->index, + funcdef_no, e->dest->index, style, color, weight, (e->flags & (EDGE_FAKE | EDGE_DFS_BACK)) ? "false" : "true"); } @@ -192,10 +166,10 @@ draw_cfg_node_succ_edges (pretty_printer *pp, int fndecl_uid, basic_block bb) /* Print a graphical representation of the CFG of function FUN. */ void -print_graph_cfg (const char *base, tree fndecl) +print_graph_cfg (const char *base, struct function *fun) { - const char *funcname = fndecl_name (fndecl); - int fndecl_uid = DECL_UID (fndecl); + const char *funcname = function_name (fun); + int funcdef_no = fun->funcdef_no; FILE *fp = open_graph_file (base, "a"); int *rpo = XNEWVEC (int, n_basic_blocks); basic_block bb; @@ -212,7 +186,7 @@ print_graph_cfg (const char *base, tree fndecl) of the nodes. */ n = pre_and_rev_post_order_compute (NULL, rpo, true); for (i = 0; i < n; i++) - draw_cfg_node (pp, fndecl_uid, BASIC_BLOCK (rpo[i])); + draw_cfg_node (pp, funcdef_no, BASIC_BLOCK (rpo[i])); /* Draw all edges at the end to get subgraphs right for GraphViz, which requires nodes to be defined before edges to cluster @@ -224,7 +198,7 @@ print_graph_cfg (const char *base, tree fndecl) for ourselves is also not desirable.) */ mark_dfs_back_edges (); FOR_ALL_BB (bb) - draw_cfg_node_succ_edges (pp, fndecl_uid, bb); + draw_cfg_node_succ_edges (pp, funcdef_no, bb); pp_printf (pp, "\t}\n"); pp_flush (pp); |