Make fehler159 compilable.
[libfirm] / ir / ana / irlivechk.c
index 4aa00d8..c31b2b9 100644 (file)
@@ -61,7 +61,7 @@
 #include "statev.h"
 
 typedef struct _bl_info_t {
-       ir_node *block;            /**< The block. */
+       const ir_node *block;      /**< The block. */
 
        int be_tgt_calc : 1;
        int id : 31;               /**< a tight number for the block.
@@ -87,7 +87,7 @@ struct _lv_chk_t {
        bl_info_t **map;
 };
 
-static void *init_block_data(ir_phase *ph, ir_node *irn, void *old)
+static void *init_block_data(ir_phase *ph, const ir_node *irn, void *old)
 {
        lv_chk_t *lv      = container_of(ph, lv_chk_t, ph);
        bl_info_t *bi     = phase_alloc(ph, sizeof(bi[0]));
@@ -112,6 +112,7 @@ static INLINE int is_liveness_node(const ir_node *irn)
        case iro_Block:
        case iro_Bad:
        case iro_End:
+       case iro_Anchor:
                return 0;
        default:;
        }
@@ -164,7 +165,7 @@ static void red_trans_closure(lv_chk_t *lv)
 
 }
 
-static void compute_back_edge_chain(lv_chk_t *lv, ir_node *bl)
+static void compute_back_edge_chain(lv_chk_t *lv, const ir_node *bl)
 {
        bitset_t *tmp = bitset_alloca(lv->n_blocks);
        bl_info_t *bi = get_block_info(lv, bl);
@@ -243,10 +244,14 @@ static INLINE void compute_back_edge_chains(lv_chk_t *lv)
 
 lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs)
 {
-       lv_chk_t *res = xmalloc(sizeof(res[0]));
+       lv_chk_t *res = XMALLOC(lv_chk_t);
        struct obstack *obst;
        int i;
 
+       edges_deactivate(irg);
+       edges_activate(irg);
+       compute_doms(irg);
+
        stat_ev_tim_push();
        phase_init(&res->ph, "liveness check", irg, PHASE_DEFAULT_GROWTH, init_block_data, NULL);
        obst = phase_obst(&res->ph);
@@ -258,6 +263,7 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs)
        res->back_edge_src = bitset_obstack_alloc(obst, res->n_blocks);
        res->back_edge_tgt = bitset_obstack_alloc(obst, res->n_blocks);
        res->map           = obstack_alloc(obst, res->n_blocks * sizeof(res->map[0]));
+       memset(res->map, 0, res->n_blocks * sizeof(res->map[0]));
 
 #if 0
        {
@@ -276,6 +282,8 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs)
        for (i = res->n_blocks - 1; i >= 0; --i) {
                ir_node *irn  = (ir_node *) dfs_get_pre_num_node(res->dfs, i);
                bl_info_t *bi = phase_get_or_set_irn_data(&res->ph, irn);
+               assert(bi->id < res->n_blocks);
+               assert(res->map[bi->id] == NULL);
                res->map[bi->id] = bi;
        }
 
@@ -305,7 +313,7 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs)
 
 void lv_chk_free(lv_chk_t *lv)
 {
-       obstack_free(phase_obst(&lv->ph), NULL);
+       phase_free(&lv->ph);
        xfree(lv);
 }