Added dominance checker
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Sun, 28 Aug 2005 12:38:47 +0000 (12:38 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Sun, 28 Aug 2005 12:38:47 +0000 (12:38 +0000)
ir/be/belive.c
ir/be/belive.h

index 98d98f3..368d8f1 100644 (file)
@@ -190,3 +190,29 @@ void be_liveness_dump(ir_graph *irg, FILE *f)
 {
        irg_block_walk_graph(irg, dump_liveness_walker, NULL, f);
 }
+
+static void dom_check(ir_node *irn, void *data)
+{
+       if(!is_block(irn)) {
+               int i, n;
+               ir_node *bl = get_nodes_block(irn);
+
+               for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
+                       ir_node *op     = get_irn_n(irn, i);
+                       ir_node *def_bl = get_nodes_block(op);
+                       ir_node *use_bl = bl;
+
+                       if(is_Phi(irn))
+                               use_bl = get_Block_cfgpred_block(bl, i);
+
+                       if(!block_dominates(def_bl, use_bl))
+                               ir_fprintf(stderr, "In %+F(%d:%+Fr): %+F must dominate %+F\n",
+                                               irn, i, op, def_bl, use_bl);
+               }
+       }
+}
+
+void be_check_dominance(ir_graph *irg)
+{
+       irg_walk_graph(irg, dom_check, NULL, NULL);
+}
index cf9c6fb..c1e58fa 100644 (file)
@@ -46,5 +46,10 @@ int (is_live_out)(const ir_node *block, const ir_node *irn);
  */
 int (is_live_end)(const ir_node *block, const ir_node *irn);
 
+/**
+ * Check, if the SSA dominance property is fulfilled.
+ * @param irg The graph.
+ */
+void be_check_dominance(ir_graph *irg);
 
 #endif