Initially mark the end block as reachable and set the bad node to bottom (i.e. undefi...
[libfirm] / ir / ana / irdom.c
index 8150d56..7db7234 100644 (file)
@@ -52,7 +52,8 @@ ir_node *get_Block_idom(const ir_node *bl)
        assert(is_Block(bl));
        if (get_Block_dom_depth(bl) == -1) {
                /* This block is not reachable from Start */
-               return new_Bad();
+               ir_graph *irg = get_irn_irg(bl);
+               return new_r_Bad(irg);
        }
        return get_dom_info(bl)->idom;
 }
@@ -83,7 +84,8 @@ ir_node *get_Block_ipostdom(const ir_node *bl)
        assert(is_Block(bl));
        if (get_Block_postdom_depth(bl) == -1) {
                /* This block is not reachable from Start */
-               return new_Bad();
+               ir_graph *irg = get_irn_irg(bl);
+               return new_r_Bad(irg);
        }
        return get_pdom_info(bl)->idom;
 }
@@ -408,7 +410,7 @@ void postdom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
 
 static void assign_tree_dom_pre_order(ir_node *bl, void *data)
 {
-       unsigned *num = data;
+       unsigned *num = (unsigned*) data;
        ir_dom_info *bi = get_dom_info(bl);
 
        bi->tree_pre_num = (*num)++;
@@ -434,7 +436,7 @@ static void assign_tree_dom_pre_order_max(ir_node *bl, void *data)
 
 static void assign_tree_postdom_pre_order(ir_node *bl, void *data)
 {
-       unsigned *num = data;
+       unsigned *num = (unsigned*) data;
        ir_dom_info *bi = get_pdom_info(bl);
 
        bi->tree_pre_num = (*num)++;
@@ -469,9 +471,6 @@ static void count_and_init_blocks_pdom(ir_node *bl, void *env)
 {
        int *n_blocks = (int *) env;
 
-       if (is_Block_dead(bl))
-               return;
-
        (*n_blocks) ++;
 
        memset(get_pdom_info(bl), 0, sizeof(ir_dom_info));
@@ -515,9 +514,6 @@ static void init_tmp_dom_info(ir_node *bl, tmp_dom_info *parent,
        tmp_dom_info *tdi;
        int i;
 
-       if (is_Block_dead(bl))
-               return;
-
        assert(is_Block(bl));
        if (Block_block_visited(bl))
          return;
@@ -557,9 +553,6 @@ static void init_tmp_pdom_info(ir_node *bl, tmp_dom_info *parent,
        tmp_dom_info *tdi;
        int i;
 
-       if (is_Block_dead(bl))
-               return;
-
        assert(is_Block(bl));
        if (get_irg_block_visited(current_ir_graph) == get_Block_block_visited(bl))
          return;
@@ -638,8 +631,6 @@ inline static void dom_link(tmp_dom_info *v, tmp_dom_info *w)
 static void count_and_init_blocks_dom(ir_node *bl, void *env)
 {
        int *n_blocks = (int *) env;
-       if (is_Block_dead(bl))
-               return;
 
        (*n_blocks) ++;
 
@@ -698,7 +689,7 @@ void compute_doms(ir_graph *irg)
                        tmp_dom_info *u;
 
                        if (is_Bad(pred) || (get_Block_dom_pre_num (pred) == -1))
-                               continue;       /* control-dead */
+                               continue;    /* control-dead */
 
                        u = dom_eval (&tdi_list[get_Block_dom_pre_num(pred)]);
                        if (u->semi < w->semi) w->semi = u->semi;
@@ -714,7 +705,7 @@ void compute_doms(ir_graph *irg)
                                tmp_dom_info *u;
 
                                if (!is_Block(pred) || get_Block_dom_pre_num(pred) == -1)
-                                       continue;       /* control-dead */
+                                       continue;   /* control-dead */
 
                                u = dom_eval (&tdi_list[get_Block_dom_pre_num(pred)]);
                                if (u->semi < w->semi) w->semi = u->semi;
@@ -840,7 +831,7 @@ void compute_postdoms(ir_graph *irg)
                        tmp_dom_info *u;
 
                        if (get_Block_postdom_pre_num (succ) == -1)
-                               continue;       /* endless-loop */
+                               continue;    /* endless-loop */
 
                        u = dom_eval (&tdi_list[get_Block_postdom_pre_num(succ)]);
                        if (u->semi < w->semi) w->semi = u->semi;