From: Michael Beck Date: Wed, 30 Jul 2008 00:58:43 +0000 (+0000) Subject: - opt_tail_recursion() must run before optimize_funccalls(): X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=887edd1f510c555fc69df94b1cd230898a9c030a;p=libfirm - opt_tail_recursion() must run before optimize_funccalls(): Add this not-unimportant info to the doxygen docu - typo fixed - add a set_using_irn_link()/clear_using_irn_link() pair [r20777] --- diff --git a/include/libfirm/iroptimize.h b/include/libfirm/iroptimize.h index 41e09aed5..88cd223ee 100644 --- a/include/libfirm/iroptimize.h +++ b/include/libfirm/iroptimize.h @@ -439,9 +439,16 @@ void reduce_strength(ir_graph *irg); */ int opt_tail_rec_irg(ir_graph *irg); -/* +/** * Optimize tail-recursion calls for all IR-Graphs. - * Depends on the flag opt_tail_recursion. + * Can currently handle: + * - direct return value, i.e. return func(). + * - additive return value, i.e. return x +/- func() + * - multiplicative return value, i.e. return x * func() or return -func() + * + * The current implementation must be run before optimize_funccalls(), + * because it expects the memory edges pointing to calls, which might be + * removed by optimize_funccalls(). */ void opt_tail_recursion(void); @@ -514,6 +521,8 @@ void optimize_class_casts(void); * * Does conditional constant propagation, unreachable code elimination and optimistic * global value numbering at once. + * + * @param irg the graph to run on */ void combo(ir_graph *irg); diff --git a/ir/opt/tailrec.c b/ir/opt/tailrec.c index 11e9088dd..55ea68a42 100644 --- a/ir/opt/tailrec.c +++ b/ir/opt/tailrec.c @@ -489,7 +489,7 @@ static tail_rec_variants find_variant(ir_node *irn, ir_node *call) { return TR_BAD; case iro_Sub: - /* try additive, but return value mut be left */ + /* try additive, but return value must be left */ a = get_Sub_left(irn); if (get_irn_MacroBlock(a) != get_irn_MacroBlock(call)) { /* we are outside, ignore */ @@ -719,8 +719,10 @@ void opt_tail_recursion(void) { current_ir_graph = irg; + set_using_irn_link(irg); if (opt_tail_rec_irg(irg)) ++n_opt_applications; + clear_using_irn_link(irg); } DB((dbg, LEVEL_1, "Performed tail recursion for %d of %d graphs\n",