diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-18 13:37:46 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-01 00:18:44 +0200 |
| commit | 242d55dba4a831b35e6f127f3b6aca3c00534426 (patch) | |
| tree | 043dd23a00440d3b6983c921dfbd9ccae9efeaa0 | |
| parent | 787153d14e2435df199186db0480ec94d9d74de0 (diff) | |
| download | sparse-dev-242d55dba4a831b35e6f127f3b6aca3c00534426.tar.gz | |
dom: add some debugging for the dominance tree
So, it's possible to use the flag '-vdomtree' to dump the
domonance tree.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | Documentation/dev-options.rst | 4 | ||||
| -rw-r--r-- | flowgraph.c | 14 | ||||
| -rw-r--r-- | lib.c | 2 | ||||
| -rw-r--r-- | lib.h | 1 |
4 files changed, 21 insertions, 0 deletions
diff --git a/Documentation/dev-options.rst b/Documentation/dev-options.rst index f6bfa79f..04fb651f 100644 --- a/Documentation/dev-options.rst +++ b/Documentation/dev-options.rst @@ -44,6 +44,10 @@ OPTIONS Add ``OP_DEATHNOTE`` annotations to dead pseudos. +.. option:: -vdomtree + + Dump the dominance tree after its calculation. + .. option:: -ventry Dump the IR after all optimization passes. diff --git a/flowgraph.c b/flowgraph.c index d5551908..b2d95893 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); } @@ -287,6 +287,7 @@ int dump_macro_defs = 0; int dbg_compound = 0; int dbg_dead = 0; +int dbg_domtree = 0; int dbg_entry = 0; int dbg_ir = 0; int dbg_postorder = 0; @@ -767,6 +768,7 @@ static char **handle_switch_W(char *arg, char **next) static struct flag debugs[] = { { "compound", &dbg_compound}, { "dead", &dbg_dead}, + { "domtree", &dbg_domtree}, { "entry", &dbg_entry}, { "ir", &dbg_ir}, { "postorder", &dbg_postorder}, @@ -176,6 +176,7 @@ extern int dump_macro_defs; extern int dbg_compound; extern int dbg_dead; +extern int dbg_domtree; extern int dbg_entry; extern int dbg_ir; extern int dbg_postorder; |
