+/**
+ * Removes a node from the list of live variables of a block.
+ * @return 1 if the node was live at that block, 0 if not.
+ */
+static int be_lv_remove(be_lv_t *li, const ir_node *bl,
+ const ir_node *irn)
+{
+ be_lv_info_t *irn_live = (be_lv_info_t*)ir_nodehashmap_get(&li->map, bl);
+
+ if (irn_live != NULL) {
+ unsigned n = irn_live[0].head.n_members;
+ unsigned idx = get_irn_idx(irn);
+ unsigned pos = _be_liveness_bsearch(irn_live, idx);
+ be_lv_info_t *payload = irn_live + 1;
+ be_lv_info_node_t *res = &payload[pos].node;
+
+ /* The node is in deed in the block's array. Let's remove it. */
+ if (res->idx == idx) {
+ unsigned i;
+
+ for (i = pos + 1; i < n; ++i)
+ payload[i - 1] = payload[i];
+
+ payload[n - 1].node.idx = 0;
+ payload[n - 1].node.flags = 0;
+
+ --irn_live[0].head.n_members;
+ DBG((dbg, LEVEL_3, "\tdeleting %+F from %+F at pos %d\n", irn, bl, pos));
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void register_node(be_lv_t *lv, const ir_node *irn)
+{
+ unsigned idx = get_irn_idx(irn);
+ if (idx >= bitset_size(lv->nodes)) {
+ bitset_t *nw = bitset_malloc(2 * idx);
+ bitset_copy_into(nw, lv->nodes);
+ bitset_free(lv->nodes);
+ lv->nodes = nw;
+ }
+
+ bitset_set(lv->nodes, idx);
+}
+
+/**
+ * Mark a node as live-in in a block.
+ */
+static inline void mark_live_in(be_lv_t *lv, ir_node *block, ir_node *irn)
+{
+ be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn);
+ DBG((dbg, LEVEL_2, "marking %+F live in at %+F\n", irn, block));
+ n->flags |= be_lv_state_in;
+ register_node(lv, irn);
+}
+
+/**
+ * Mark a node as live-out in a block.
+ */
+static inline void mark_live_out(be_lv_t *lv, ir_node *block, ir_node *irn)
+{
+ be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn);
+ DBG((dbg, LEVEL_2, "marking %+F live out at %+F\n", irn, block));
+ n->flags |= be_lv_state_out | be_lv_state_end;
+ register_node(lv, irn);
+}
+
+/**
+ * Mark a node as live-end in a block.
+ */
+static inline void mark_live_end(be_lv_t *lv, ir_node *block, ir_node *irn)
+{
+ be_lv_info_node_t *n = be_lv_get_or_set(lv, block, irn);
+ DBG((dbg, LEVEL_2, "marking %+F live end at %+F\n", irn, block));
+ n->flags |= be_lv_state_end;
+ register_node(lv, irn);
+}
+
+static struct {
+ be_lv_t *lv; /**< The liveness object. */
+ ir_node *def; /**< The node (value). */
+ ir_node *def_block; /**< The block of def. */
+ bitset_t *visited; /**< A set were all visited blocks are recorded. */
+} re;
+