So, it's possible to use the flag '-vdomtree' to dump the domonance tree. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- Documentation/dev-options.md | 1 + flowgraph.c | 14 ++++++++++++++ lib.c | 2 ++ lib.h | 1 + 4 files changed, 18 insertions(+) diff --git a/Documentation/dev-options.md b/Documentation/dev-options.md index b288d904c..882a566aa 100644 --- a/Documentation/dev-options.md +++ b/Documentation/dev-options.md @@ -31,5 +31,6 @@ document options only useful for development on sparse itself. Add or display some debug info. The flag can be one of: * 'dead': annotate dead pseudos. + * 'domtree': dump the dominance tree after its calculation. * 'entry': dump the IR after all optimization passes. * 'postorder': dump the reverse postorder traversal of the CFG. diff --git a/flowgraph.c b/flowgraph.c index d5551908e..b2d95893c 100644 --- a/flowgraph.c +++ b/flowgraph.c @@ -102,6 +102,18 @@ static struct basic_block *intersect_dom(struct basic_block *doms[], return b1; } +static void debug_domtree(struct entrypoint *ep) +{ + struct basic_block *bb = ep->entry->bb; + + printf("%s's idoms:\n", show_ident(ep->name->ident)); + FOR_EACH_PTR(ep->bbs, bb) { + if (bb == ep->entry->bb) + continue; // entry node has no idom + printf("\t%s <- %s\n", show_label(bb), show_label(bb->idom)); + } END_FOR_EACH_PTR(bb); +} + void domtree_build(struct entrypoint *ep) { struct basic_block *entry = ep->entry->bb; @@ -178,4 +190,6 @@ void domtree_build(struct entrypoint *ep) ep->dom_levels = max_level + 1; free(doms); + if (dbg_domtree) + debug_domtree(ep); } diff --git a/lib.c b/lib.c index 26645b156..904008b43 100644 --- a/lib.c +++ b/lib.c @@ -258,6 +258,7 @@ int dump_macro_defs = 0; int dbg_entry = 0; int dbg_dead = 0; +int dbg_domtree = 0; int dbg_postorder = 0; unsigned long fdump_ir; @@ -718,6 +719,7 @@ static char **handle_switch_W(char *arg, char **next) static struct flag debugs[] = { { "entry", &dbg_entry}, { "dead", &dbg_dead}, + { "domtree", &dbg_domtree}, { "postorder", &dbg_postorder}, }; diff --git a/lib.h b/lib.h index 321655485..3eb8adc73 100644 --- a/lib.h +++ b/lib.h @@ -167,6 +167,7 @@ extern int dump_macro_defs; extern int dbg_entry; extern int dbg_dead; +extern int dbg_domtree; extern int dbg_postorder; extern unsigned int fmax_warnings; -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html