[PATCH v1 02/18] graph: add debugging for (reverse) postorder traversal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just use the flag '-vpostorder' to dump the links once calculated.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 Documentation/dev-options.md |  1 +
 flowgraph.c                  | 13 +++++++++++++
 lib.c                        |  2 ++
 lib.h                        |  1 +
 4 files changed, 17 insertions(+)

diff --git a/Documentation/dev-options.md b/Documentation/dev-options.md
index 7c278135a..b288d904c 100644
--- a/Documentation/dev-options.md
+++ b/Documentation/dev-options.md
@@ -32,3 +32,4 @@ 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.
   * '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 89897fa48..40a75e825 100644
--- a/flowgraph.c
+++ b/flowgraph.c
@@ -8,6 +8,7 @@
 #include "flowgraph.h"
 #include "linearize.h"
 #include "flow.h"			// for bb_generation
+#include <stdio.h>
 
 
 struct cfg_info {
@@ -41,6 +42,16 @@ static void reverse_bbs(struct basic_block_list **dst, struct basic_block_list *
 	} END_FOR_EACH_PTR_REVERSE(bb);
 }
 
+static void debug_postorder(struct entrypoint *ep)
+{
+	struct basic_block *bb;
+
+	printf("%s's reverse postorder:\n", show_ident(ep->name->ident));
+	FOR_EACH_PTR(ep->bbs, bb) {
+		printf("\t.L%u: %u\n", bb->nr, bb->postorder_nr);
+	} END_FOR_EACH_PTR(bb);
+}
+
 //
 // cfg_postorder - Set the BB's reverse postorder links
 //
@@ -61,5 +72,7 @@ int cfg_postorder(struct entrypoint *ep)
 	ep->bbs = NULL;
 	reverse_bbs(&ep->bbs, info.list);
 	free_ptr_list(&info.list);
+	if (dbg_postorder)
+		debug_postorder(ep);
 	return info.nr;
 }
diff --git a/lib.c b/lib.c
index 73d372c36..26645b156 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_postorder = 0;
 
 unsigned long fdump_ir;
 int fmem_report = 0;
@@ -717,6 +718,7 @@ static char **handle_switch_W(char *arg, char **next)
 static struct flag debugs[] = {
 	{ "entry", &dbg_entry},
 	{ "dead", &dbg_dead},
+	{ "postorder", &dbg_postorder},
 };
 
 
diff --git a/lib.h b/lib.h
index 3050b5577..321655485 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_postorder;
 
 extern unsigned int fmax_warnings;
 extern int fmem_report;
-- 
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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux