-/**
- * 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 (get_irn_op(pred) == op_Block) {
- if (Block_not_block_visited(pred)) {
- /* we found a endless loop */
- dec_irg_block_visited(irg);
- irg_block_walk(pred, pre, NULL, &n_blocks);
- }
- else
- continue;
- }
- in[j++] = pred;
- }
- if (j != arity) {
- /* we kill some Block keep-alives */
- set_End_keepalives(end, j, in);
- set_irg_outs_inconsistent(irg);
- }
- }
-
- current_ir_graph = rem;
- return n_blocks;
-}
-
-