Hi, This adds a debug function to dump the dominator tree in dot/graphviz format. The idea is that the function can be called in GDB, the output copy/pasted into a .dot file and then rendered using graphviz.
Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk? Thanks, Alex gcc/ChangeLog: * dominance.cc (debug_dominance_tree_dot): New.
diff --git a/gcc/dominance.cc b/gcc/dominance.cc index 0357210ed27..b536f193abc 100644 --- a/gcc/dominance.cc +++ b/gcc/dominance.cc @@ -1658,6 +1658,20 @@ debug_dominance_info (enum cdi_direction dir) fprintf (stderr, "%i %i\n", bb->index, bb2->index); } +/* Print the dominance tree (in direction DIR) in dot form. This allows easily + visualizing the tree using graphviz. */ + +DEBUG_FUNCTION void +debug_dominance_tree_dot (enum cdi_direction dir) +{ + fprintf (stderr, "digraph {\n"); + basic_block bb, idom; + FOR_EACH_BB_FN (bb, cfun) + if ((idom = get_immediate_dominator (dir, bb))) + fprintf (stderr, "%i -> %i;\n", idom->index, bb->index); + fprintf (stderr, "}\n"); +} + /* Prints to stderr representation of the dominance tree (for direction DIR) rooted in ROOT, indented by INDENT tabulators. If INDENT_FIRST is false, the first line of the output is not indented. */