aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--Documentation/dev-options.rst4
-rw-r--r--flowgraph.c14
-rw-r--r--lib.c2
-rw-r--r--lib.h1
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);
}
diff --git a/lib.c b/lib.c
index a13f0e1a..1c556e22 100644
--- a/lib.c
+++ b/lib.c
@@ -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},
diff --git a/lib.h b/lib.h
index a3f29609..68369190 100644
--- a/lib.h
+++ b/lib.h
@@ -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;