Set the outs to inconsistent at the end of transform_irg().
[libfirm] / ir / opt / cfopt.c
index 6fa73c7..945767a 100644 (file)
@@ -62,6 +62,8 @@
 /* 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.                                                       */
 /*------------------------------------------------------------------*/
 
 /**
@@ -226,10 +228,14 @@ static void collect_nodes(ir_node *n, void *ctx) {
        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 labelled */
+    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);