+ if(get_irn_opcode(use_bl) != iro_Bad
+ && get_irn_opcode(def_bl) != iro_Bad
+ && !block_dominates(def_bl, use_bl)) {
+ ir_fprintf(stderr, "Verify warning: %+F in %+F must dominate %+F for user %+F (%s)\n", op, def_bl, use_bl, irn, get_irg_dump_name(get_irn_irg(op)));
+ *problem_found = 1;
+ }
+ }
+ }
+}
+
+/* Check, if the SSA dominance property is fulfilled. */
+int be_check_dominance(ir_graph *irg)
+{
+ int problem_found = 0;
+
+ assure_doms(irg);
+ irg_walk_graph(irg, dom_check, NULL, &problem_found);
+
+ return !problem_found;
+}
+
+void be_liveness_transfer(const arch_env_t *arch_env,
+ const arch_register_class_t *cls,
+ ir_node *node, ir_nodeset_t *nodeset)
+{
+ int i, arity;
+
+ /* You should better break out of your loop when hitting the first phi
+ * function. */
+ assert(!is_Phi(node) && "liveness_transfer produces invalid results for phi nodes");
+
+ if (get_irn_mode(node) == mode_T) {
+ const ir_edge_t *edge;
+
+ foreach_out_edge(node, edge) {
+ ir_node *proj = get_edge_src_irn(edge);
+
+ if (arch_irn_consider_in_reg_alloc(arch_env, cls, proj)) {
+ ir_nodeset_remove(nodeset, proj);
+ }
+ }
+ } else if (arch_irn_consider_in_reg_alloc(arch_env, cls, node)) {
+ ir_nodeset_remove(nodeset, node);
+ }
+
+ arity = get_irn_arity(node);
+ for (i = 0; i < arity; ++i) {
+ ir_node *op = get_irn_n(node, i);
+
+ if (arch_irn_consider_in_reg_alloc(arch_env, cls, op))
+ ir_nodeset_insert(nodeset, op);
+ }
+}
+
+
+
+void be_liveness_end_of_block(const be_lv_t *lv, const arch_env_t *arch_env,
+ const arch_register_class_t *cls,
+ const ir_node *block, ir_nodeset_t *live)
+{
+ int i;
+
+ assert(lv->nodes && "live sets must be computed");
+ be_lv_foreach(lv, block, be_lv_state_end, i) {
+ ir_node *node = be_lv_get_irn(lv, block, i);
+ if(!arch_irn_consider_in_reg_alloc(arch_env, cls, node))
+ continue;
+
+ ir_nodeset_insert(live, node);
+ }
+}
+
+
+
+void be_liveness_nodes_live_at(const be_lv_t *lv, const arch_env_t *arch_env,
+ const arch_register_class_t *cls,
+ const ir_node *pos, ir_nodeset_t *live)
+{
+ const ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
+ ir_node *irn;
+
+ be_liveness_end_of_block(lv, arch_env, cls, bl, live);
+ sched_foreach_reverse(bl, irn) {
+ /*
+ * If we encounter the node we want to insert the Perm after,
+ * exit immediately, so that this node is still live
+ */
+ if(irn == pos)
+ return;
+
+ be_liveness_transfer(arch_env, cls, irn, live);
+ }
+}
+
+void be_liveness_nodes_live_at_input(const be_lv_t *lv,
+ const arch_env_t *arch_env,
+ const arch_register_class_t *cls,
+ const ir_node *pos, ir_nodeset_t *live)
+{
+ const ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
+ ir_node *irn;
+
+ assert(lv->nodes && "live sets must be computed");
+ be_liveness_end_of_block(lv, arch_env, cls, bl, live);
+ sched_foreach_reverse(bl, irn) {
+ be_liveness_transfer(arch_env, cls, irn, live);
+ if(irn == pos)
+ return;
+ }
+}
+
+static void collect_node(ir_node *irn, void *data)
+{
+ struct obstack *obst = data;
+ obstack_ptr_grow(obst, irn);
+}
+
+void be_live_chk_compare(be_lv_t *lv, lv_chk_t *lvc)
+{
+ ir_graph *irg = lv->irg;
+
+ struct obstack obst;
+ ir_node **nodes;
+ ir_node **blocks;
+ int i, j;
+
+ obstack_init(&obst);
+
+ irg_block_walk_graph(irg, collect_node, NULL, &obst);
+ obstack_ptr_grow(&obst, NULL);
+ blocks = obstack_finish(&obst);
+
+ irg_walk_graph(irg, collect_node, NULL, &obst);
+ obstack_ptr_grow(&obst, NULL);
+ nodes = obstack_finish(&obst);
+
+ stat_ev_ctx_push("be_lv_chk_compare");
+ for (j = 0; nodes[j]; ++j) {
+ ir_node *irn = nodes[j];
+ for (i = 0; blocks[i]; ++i) {
+ ir_node *bl = blocks[i];
+
+ if (!is_Block(irn)) {
+ int lvr_in = be_is_live_in (lv, bl, irn);
+ int lvr_out = be_is_live_out(lv, bl, irn);
+ int lvr_end = be_is_live_end(lv, bl, irn);
+
+ int lvc_in = lv_chk_bl_in (lvc, bl, irn);
+ int lvc_out = lv_chk_bl_out(lvc, bl, irn);
+ int lvc_end = lv_chk_bl_end(lvc, bl, irn);
+
+ if (lvr_in - lvc_in != 0)
+ ir_fprintf(stderr, "live in info for %+F at %+F differs: nml: %d, chk: %d\n", irn, bl, lvr_in, lvc_in);
+
+ if (lvr_end - lvc_end != 0)
+ ir_fprintf(stderr, "live end info for %+F at %+F differs: nml: %d, chk: %d\n", irn, bl, lvr_end, lvc_end);
+
+ if (lvr_out - lvc_out != 0)
+ ir_fprintf(stderr, "live out info for %+F at %+F differs: nml: %d, chk: %d\n", irn, bl, lvr_out, lvc_out);