+
+ 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(cls, op))
+ ir_nodeset_insert(nodeset, op);
+ }
+}
+
+
+
+void be_liveness_end_of_block(const be_lv_t *lv,
+ const arch_register_class_t *cls,
+ const ir_node *block, ir_nodeset_t *live)
+{
+ assert(lv->sets_valid && "live sets must be computed");
+ be_lv_foreach(lv, block, be_lv_state_end, node) {
+ if (!arch_irn_consider_in_reg_alloc(cls, node))
+ continue;
+
+ ir_nodeset_insert(live, node);
+ }
+}
+
+
+
+void be_liveness_nodes_live_at(const be_lv_t *lv,
+ 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);
+
+ be_liveness_end_of_block(lv, 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(cls, irn, live);
+ }
+}
+
+static void collect_node(ir_node *irn, void *data)
+{
+ struct obstack *obst = (struct obstack*)data;
+ obstack_ptr_grow(obst, irn);
+}
+
+static 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 = (ir_node**)obstack_finish(&obst);
+
+ irg_walk_graph(irg, collect_node, NULL, &obst);
+ obstack_ptr_grow(&obst, NULL);
+ nodes = (ir_node**)obstack_finish(&obst);
+
+ stat_ev_ctx_push("be_lv_chk_compare");
+ for (j = 0; nodes[j]; ++j) {
+ ir_node *irn = nodes[j];
+ if (is_Block(irn))
+ continue;
+
+ for (i = 0; blocks[i]; ++i) {
+ ir_node *bl = blocks[i];
+ 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);
+ }
+ }
+ stat_ev_ctx_pop("be_lv_chk_compare");
+
+ obstack_free(&obst, NULL);