X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firdom.c;h=ff572d8de4e40c5ebe8045d8baa87db802545de9;hb=ceefa5a3e6ff610b4b7d92033b8c2443cbc07938;hp=9d4e8f944bdd3341ee0d797477ccc25570909dfa;hpb=2807bb5b1ed34c23dc30d228ab0686c6fc9d6ae3;p=libfirm diff --git a/ir/ana/irdom.c b/ir/ana/irdom.c index 9d4e8f944..ff572d8de 100644 --- a/ir/ana/irdom.c +++ b/ir/ana/irdom.c @@ -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)++; @@ -468,6 +470,10 @@ static void assign_tree_postdom_pre_order_max(ir_node *bl, void *data) 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)); @@ -511,6 +517,9 @@ 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; @@ -550,6 +559,9 @@ 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; @@ -628,6 +640,9 @@ 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) ++; memset(get_dom_info(bl), 0, sizeof(ir_dom_info)); @@ -636,28 +651,6 @@ static void count_and_init_blocks_dom(ir_node *bl, void *env) set_Block_dom_depth(bl, -1); } -/** - * Initialize the dominance/postdominance construction: - * - * - count the number of blocks - * - clear the dominance info - * - remove Block-keepalives of live blocks to reduce - * the number of "phantom" block edges - * - * @param irg the graph - * @param pre a walker function that will be called for every block in the graph - */ -static int init_construction(ir_graph *irg, irg_walk_func *pre) -{ - int n_blocks = 0; - - /* this visits only the reachable blocks */ - irg_block_walk_graph(irg, pre, NULL, &n_blocks); - - return n_blocks; -} - - /* Computes the dominator trees. Sets a flag in irg to "dom_consistent". If the control flow of the graph is changed this flag must be set to "dom_inconsistent". */ @@ -674,7 +667,8 @@ void compute_doms(ir_graph *irg) irg->dom_state = dom_consistent; /* Count the number of blocks in the graph. */ - n_blocks = init_construction(irg, count_and_init_blocks_dom); + n_blocks = 0; + irg_block_walk_graph(irg, count_and_init_blocks_dom, NULL, &n_blocks); /* Memory for temporary information. */ tdi_list = XMALLOCNZ(tmp_dom_info, n_blocks); @@ -706,7 +700,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; @@ -721,8 +715,8 @@ void compute_doms(ir_graph *irg) ir_node *pred = get_irn_n(end, j); tmp_dom_info *u; - if (is_no_Block(pred) || get_Block_dom_pre_num(pred) == -1) - continue; /* control-dead */ + if (!is_Block(pred) || get_Block_dom_pre_num(pred) == -1) + continue; /* control-dead */ u = dom_eval (&tdi_list[get_Block_dom_pre_num(pred)]); if (u->semi < w->semi) w->semi = u->semi; @@ -816,7 +810,8 @@ void compute_postdoms(ir_graph *irg) irg->pdom_state = dom_consistent; /* Count the number of blocks in the graph. */ - n_blocks = init_construction(irg, count_and_init_blocks_pdom); + n_blocks = 0; + irg_block_walk_graph(irg, count_and_init_blocks_pdom, NULL, &n_blocks); /* Memory for temporary information. */ tdi_list = XMALLOCNZ(tmp_dom_info, n_blocks); @@ -847,7 +842,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;