- /* Handle graph state */
- set_irg_outs_inconsistent(current_ir_graph);
- set_irg_extblk_inconsistent(current_ir_graph);
- set_irg_loopinfo_inconsistent(current_ir_graph);
- set_irg_doms_inconsistent(current_ir_graph);
-
- if (dom_state == dom_consistent && get_opt_optimize() && get_opt_unreachable_code()) {
- ir_node *end;
-
- /* we have dominance info, we can kill dead block */
- irg_block_walk_graph(irg, NULL, remove_dead_block_cf, NULL);
-
- /* fix the keep-alives */
- end = get_irg_end(irg);
- for (i = 0, n = get_End_n_keepalives(end); i < n; ++i) {
- ir_node *ka = get_End_keepalive(end, i);
-
- if (is_Block(ka)) {
- /* do NOT keep dead blocks */
- if (get_Block_dom_depth(ka) < 0)
- set_End_keepalive(end, i, new_Bad());
- } else if (is_Block_dead(get_nodes_block(ka)) ||
- get_Block_dom_depth(get_nodes_block(ka)) < 0)
- /* do NOT keep nodes in dead blocks */
+ /* we use the mark flag to mark removable blocks */
+ set_using_block_mark(irg);
+restart:
+ env.changed = 0;
+ env.phis_moved = 0;
+
+ /* ALWAYS kill unreachable control flow. Backend cannot handle it anyway.
+ Use dominator info to kill blocks. Also optimize useless Conds. */
+ assure_doms(irg);
+ irg_block_walk_graph(irg, NULL, remove_unreachable_blocks_and_conds, &env.changed);
+
+ /* fix the keep-alives */
+ for (i = 0, n = get_End_n_keepalives(end); i < n; ++i) {
+ ir_node *ka = get_End_keepalive(end, i);
+
+ if (is_Block(ka)) {
+ /* do NOT keep dead blocks */
+ if (is_Block_dead(ka) || get_Block_dom_depth(ka) < 0) {