* If we don't set the root of the dominator tree
* Append bl to the dominates queue of n.
*/
- if(n != NULL) {
+ if (n != NULL) {
ir_dom_info *ni = get_dom_info(n);
bli->next = ni->first;
* If we don't set the root of the post dominator tree
* Append bl to the post dominates queue of n.
*/
- if(n != NULL) {
+ if (n != NULL) {
ir_dom_info *ni = get_pdom_info(n);
bli->next = ni->first;
{
ir_node *p;
- if(pre)
+ if (pre)
pre(bl, env);
dominates_for_each(bl, p) {
dom_tree_walk(p, pre, post, env);
}
- if(post)
+ if (post)
post(bl, env);
}
{
ir_node *p;
- if(pre)
+ if (pre)
pre(bl, env);
postdominates_for_each(bl, p) {
postdom_tree_walk(p, pre, post, env);
}
- if(post)
+ if (post)
post(bl, env);
}
unsigned children = 0;
(void) data;
- for(p = bi->first; p; p = get_dom_info(p)->next) {
+ 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++;
unsigned children = 0;
(void) data;
- for(p = bi->first; p; p = get_pdom_info(p)->next) {
+ for (p = bi->first; p; p = get_pdom_info(p)->next) {
unsigned max_p = get_pdom_info(p)->max_subtree_pre_num;
max = max > max_p ? max : max_p;
children++;
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));
* Start block misses control dead blocks.
*/
static void init_tmp_dom_info(ir_node *bl, tmp_dom_info *parent,
- tmp_dom_info *tdi_list, int *used, int n_blocks) {
+ tmp_dom_info *tdi_list, int *used, int n_blocks)
+{
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))
+ if (Block_block_visited(bl))
return;
mark_Block_block_visited(bl);
set_Block_dom_pre_num(bl, *used);
* End block misses blocks in endless loops.
*/
static void init_tmp_pdom_info(ir_node *bl, tmp_dom_info *parent,
- tmp_dom_info *tdi_list, int* used, int n_blocks) {
+ tmp_dom_info *tdi_list, int* used, int n_blocks)
+{
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;
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));
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)
-{
- ir_graph *rem = current_ir_graph;
- ir_node *end;
- int arity;
- int n_blocks = 0;
-
- current_ir_graph = irg;
-
- /* this visits only the reachable blocks */
- irg_block_walk(get_irg_end_block(irg), pre, NULL, &n_blocks);
-
- /* now visit the unreachable (from End) Blocks and remove unnecessary keep-alives */
- end = get_irg_end(irg);
- arity = get_End_n_keepalives(end);
- if (arity) { /* we have keep-alives */
- ir_node **in;
- int i, j;
-
- NEW_ARR_A(ir_node *, in, arity);
- for (i = j = 0; i < arity; i++) {
- ir_node *pred = get_End_keepalive(end, i);
-
- if (!is_Block(pred)) {
- pred = get_nodes_block(pred);
- if (!is_Block(pred)) {
- /* a node which has a bad block input: kill it */
- continue;
- }
- }
- dec_irg_block_visited(irg);
- irg_block_walk(pred, pre, NULL, &n_blocks);
- in[j++] = pred;
- }
- if (j != arity) {
- /* we kill some keep-alives */
- set_End_keepalives(end, j, in);
- set_irg_outs_inconsistent(irg);
- }
- }
-
- current_ir_graph = rem;
- 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". */
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);
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);