X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firdom.c;h=ffb2c97b91c8bab517920251c73d233b62f84811;hb=4bad1346ff2abc3923beea23e5ac949acc7ca514;hp=cd327c272962f94e6b2d209d9c6e98f83862b430;hpb=fabdda5448f5443edc7fdbb7167a8328197d32e1;p=libfirm diff --git a/ir/ana/irdom.c b/ir/ana/irdom.c index cd327c272..ffb2c97b9 100644 --- a/ir/ana/irdom.c +++ b/ir/ana/irdom.c @@ -123,18 +123,15 @@ void dom_tree_walk(ir_node *bl, irg_walk_func *pre, { ir_node *p; - assert(get_irn_irg(bl)->dom_state == dom_consistent - && "The dominators of the irg must be consistent"); + if(pre) + pre(bl, env); dominates_for_each(bl, p) { - if(pre) - pre(p, env); - dom_tree_walk(p, pre, post, env); - - if(post) - post(p, env); } + + if(post) + post(bl, env); } void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre, @@ -155,6 +152,7 @@ static void assign_tree_pre_order(ir_node *bl, void *data) { unsigned *num = data; dom_info *bi = get_dom_info(bl); + bi->tree_pre_num = (*num)++; } @@ -163,13 +161,16 @@ static void assign_tree_pre_order_max(ir_node *bl, void *data) dom_info *bi = get_dom_info(bl); ir_node *p; unsigned max = 0; + unsigned children = 0; for(p = bi->first; p; p = get_dom_info(p)->next) { unsigned max_p = get_dom_info(p)->max_subtree_pre_num; max = max > max_p ? max : max_p; + children++; } - bi->max_subtree_pre_num = max; + bi->max_subtree_pre_num = children > 0 ? max : bi->tree_pre_num; + assert(bi->max_subtree_pre_num >= bi->tree_pre_num); } /*--------------------------------------------------------------------*/