From: Michael Beck Date: Tue, 4 Mar 2008 13:32:09 +0000 (+0000) Subject: BugFix: when deleting keep-alives of already visited blocks, keep in mind X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4be066dfad695f9ed2801882fdd0ad1e82286b78;p=libfirm BugFix: when deleting keep-alives of already visited blocks, keep in mind that new keep-alives could be added because the cf was changed ... So do NOT delete these new KA ... This fixes segfault4.c [r17955] --- diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index 5ff0ab1ec..26dd09c54 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -184,7 +184,7 @@ void optimize_graph_df(ir_graph *irg) { pdeq *waitq = new_pdeq(); ir_graph *rem = current_ir_graph; ir_node *end; - int i, state; + int i, state, n_ka; current_ir_graph = irg; @@ -207,13 +207,22 @@ void optimize_graph_df(ir_graph *irg) { set_using_irn_link(irg); + end = get_irg_end(irg); + n_ka = get_End_n_keepalives(end); + /* walk over the graph, but don't touch keep-alives */ irg_walk(get_irg_end_block(irg), NULL, opt_walker, waitq); - end = get_irg_end(irg); - - /* optimize keep-alives by removing superfluous ones */ - for (i = get_End_n_keepalives(end) - 1; i >= 0; --i) { + /* + * Optimize keep-alives by removing superfluous ones. + * Beware: the last transformation might add new keep-alives + * that keep blocks that are where visited! So, check only the + * "old" keep-alives, not the new ones! + * + * FIXME: it might be better to completely remove this + * optimization here ... + */ + for (i = n_ka - 1; i >= 0; --i) { ir_node *ka = get_End_keepalive(end, i); if (irn_visited(ka) && !is_irn_keep(ka)) {