{
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,
{
unsigned *num = data;
dom_info *bi = get_dom_info(bl);
+
bi->tree_pre_num = (*num)++;
}
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);
}
/*--------------------------------------------------------------------*/