/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
/* is empty if it contains only a Jmp node. */
/* Blocks can only be removed if they are not needed for the */
/* semantics of Phi nodes. */
+/* Further, we NEVER remove labeled blocks (even if we could move */
+/* the label. */
/*------------------------------------------------------------------*/
/**
}
}
-
/**
* Block walker removing control flow from dead block by
* inspecting dominance info.
ir_op *op = get_irn_op(n);
merge_env *env = ctx;
- if (op != op_Block) {
+ if (op == op_Block) {
+ /* mark the block as non-empty if it is labeled */
+ if (has_Block_label(n))
+ mark_Block_block_visited(n);
+ } else {
ir_node *b = get_nodes_block(n);
- if (op == op_Phi) {
+ if (op == op_Phi && get_irn_arity(n) > 0) {
/* Collect Phi nodes to compact ins along with block's ins. */
set_irn_link(n, get_irn_link(b));
set_irn_link(b, n);
}
/* Seems to be empty. At least we detected this in collect_nodes. */
- if (!get_irn_link(b)) {
+ if (get_irn_link(b) == NULL) {
/* There are no Phi nodes ==> all predecessors are dispensable. */
n_preds = get_Block_n_cfgpreds(pred);
} else {
/* in rare cases a node may be kept alive more than once, use the visited flag to detect this */
inc_irg_visited(irg);
- set_using_visited(irg);
+ set_using_irn_visited(irg);
/* fix the keep alive */
for (i = j = 0; i < n; i++) {
env.changed = 1;
}
- clear_using_visited(irg);
+ clear_using_irn_visited(irg);
if (env.phis_moved) {
/* Bad: when we moved Phi's, we might produce dead Phi nodes