X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firgopt.c;h=ed973803bc1e56ce55b9f910c0eed01d1119693d;hb=31ef53136fdb86d4a98919c2148c95cadea4ea81;hp=cfe233d810daa86f455c7e17bfe8a984ea609f06;hpb=b5a6630c53c6b53a7830ec904e890ab1cd12cc0b;p=libfirm diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index cfe233d81..ed973803b 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -166,11 +166,11 @@ static void opt_walker(ir_node *n, void *env) { } /* Applies local optimizations to all nodes in the graph until fixpoint. */ -void optimize_graph_df(ir_graph *irg) { +int optimize_graph_df(ir_graph *irg) { pdeq *waitq = new_pdeq(); ir_graph *rem = current_ir_graph; ir_node *end; - int i, state, n_ka; + int i, state, n_ka, changed; current_ir_graph = irg; @@ -191,7 +191,7 @@ void optimize_graph_df(ir_graph *irg) { set_irg_doms_inconsistent(irg); set_irg_loopinfo_inconsistent(irg); - set_using_irn_link(irg); + ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK); end = get_irg_end(irg); n_ka = get_End_n_keepalives(end); @@ -220,6 +220,10 @@ void optimize_graph_df(ir_graph *irg) { set_irg_visited(current_ir_graph, get_irg_visited(irg) - 1); irg_walk(get_irg_end(irg), NULL, opt_walker, waitq); + /* any optimized nodes are stored in the wait queue, + * so if it's not empty, the graph has been changed */ + changed = !pdeq_empty(waitq); + /* finish the wait queue */ while (! pdeq_empty(waitq)) { ir_node *n = pdeq_getl(waitq); @@ -229,10 +233,11 @@ void optimize_graph_df(ir_graph *irg) { del_pdeq(waitq); - clear_using_irn_link(irg); + ir_free_resources(irg, IR_RESOURCE_IRN_LINK); if (! state) edges_deactivate(irg); current_ir_graph = rem; + return changed; }