- More restructureation:
[libfirm] / ir / be / beirgmod.c
index cfcbac6..387d994 100644 (file)
@@ -53,6 +53,7 @@
 #include "iredges_t.h"
 #include "irgraph_t.h"
 #include "irgopt.h"
+#include "irgmod.h"
 #include "irprintf_t.h"
 #include "irgwalk.h"
 
@@ -192,7 +193,7 @@ static void remove_empty_block(ir_node *block)
        }
 
        /* there can be some non-scheduled Pin nodes left in the block, move them
-        * to the succ block */
+        * to the succ block (Pin) or pred block (Sync) */
        foreach_out_edge_safe(block, edge, next) {
                node = get_edge_src_irn(edge);
 
@@ -212,11 +213,16 @@ static void remove_empty_block(ir_node *block)
                        set_nodes_block(node, get_nodes_block(pred));
                        continue;
                }
+               if (is_End(node)) { /* End-keep, reroute it to the successor */
+                       int pos = get_edge_src_pos(edge);
+                       set_irn_n(node, pos, succ_block);
+                       continue;
+               }
                panic("Unexpected node %+F in block %+F with empty schedule", node, block);
        }
 
        set_Block_cfgpred(block, 0, new_Bad());
-       be_kill_node(jump);
+       kill_node(jump);
        blocks_removed = 1;
 
        /* check predecessor */
@@ -257,6 +263,7 @@ int be_remove_empty_blocks(ir_graph *irg)
                set_irg_doms_inconsistent(irg);
                set_irg_extblk_inconsistent(irg);
                set_irg_outs_inconsistent(irg);
+               set_irg_loopinfo_inconsistent(irg);
        }
        return blocks_removed;
 }