+
+static void dump_liveness_walker(ir_node *bl, void *data)
+{
+ FILE *f = data;
+ const irn_live_t *li;
+ char buf[64];
+
+ ir_fprintf(f, "%+F\n", bl);
+ live_foreach(bl, li) {
+ strcpy(buf, "");
+
+ if(live_is_in(li))
+ strcat(buf, "in ");
+
+ if(live_is_end(li))
+ strcat(buf, "end ");
+
+ if(live_is_out(li))
+ strcat(buf, "out ");
+
+ ir_fprintf(f, "\t%+20F %s\n", li->irn, buf);
+ }
+}
+
+void be_liveness_dump(ir_graph *irg, FILE *f)
+{
+ irg_block_walk_graph(irg, dump_liveness_walker, NULL, f);
+}
+
+void be_liveness_dumpto(ir_graph *irg, const char *cls_name)
+{
+ FILE *f;
+ char buf[128];
+ ir_snprintf(buf, sizeof(buf), "%F_%s-live.txt", irg, cls_name);
+ if((f = fopen(buf, "wt")) != NULL) {
+ be_liveness_dump(irg, f);
+ fclose(f);
+ }
+}
+
+static void dom_check(ir_node *irn, void *data)
+{
+ if(!is_Block(irn) && irn != get_irg_end(get_irn_irg(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, "%+F in %+F must dominate %+F for user %+F\n", op, def_bl, use_bl, irn);
+ assert(0);
+ }
+ }
+ }
+}
+
+void be_check_dominance(ir_graph *irg)
+{
+ irg_walk_graph(irg, dom_check, NULL, NULL);
+}