X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fcfopt.c;h=be03bfad64181658cfd6db7625f869410fb28301;hb=65220b7e75f02562c05ea53f2e31556e23ef9b11;hp=6fa73c7bfa20c2ae983c0e85166d16ab5796ba13;hpb=1ec30d95387eb392ba5a1adc7958ebd91383d59c;p=libfirm diff --git a/ir/opt/cfopt.c b/ir/opt/cfopt.c index 6fa73c7bf..be03bfad6 100644 --- a/ir/opt/cfopt.c +++ b/ir/opt/cfopt.c @@ -1,5 +1,5 @@ /* - * 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. * @@ -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. */ /*------------------------------------------------------------------*/ /** @@ -185,7 +187,6 @@ static void merge_blocks(ir_node *node, void *ctx) { } } - /** * Block walker removing control flow from dead block by * inspecting dominance info. @@ -226,10 +227,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 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); @@ -308,7 +313,7 @@ static int test_whether_dispensable(ir_node *b, int pos) { } /* 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 { @@ -772,7 +777,7 @@ void optimize_cf(ir_graph *irg) { /* 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++) { @@ -805,7 +810,7 @@ void optimize_cf(ir_graph *irg) { 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