fixed svn properties
[libfirm] / ir / opt / cfopt.c
index b504e6f..945767a 100644 (file)
@@ -27,6 +27,8 @@
 # include "config.h"
 #endif
 
+#include "iroptimize.h"
+
 #include <assert.h>
 
 #include "plist.h"
@@ -51,7 +53,6 @@
 #include "irflag_t.h"
 #include "firmstat.h"
 
-#include "cfopt.h"
 #include "iropt_dbg.h"
 
 /*------------------------------------------------------------------*/
@@ -61,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.                                                       */
 /*------------------------------------------------------------------*/
 
 /**
@@ -225,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);