- opt_tail_recursion() must run before optimize_funccalls():
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 30 Jul 2008 00:58:43 +0000 (00:58 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 30 Jul 2008 00:58:43 +0000 (00:58 +0000)
  Add this not-unimportant info to the doxygen docu
- typo fixed
- add a set_using_irn_link()/clear_using_irn_link() pair

[r20777]

include/libfirm/iroptimize.h
ir/opt/tailrec.c

index 41e09ae..88cd223 100644 (file)
@@ -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);
 
index 11e9088..55ea68a 100644 (file)
@@ -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",