X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ftailrec.c;h=28ab28faabb9ae8af4951320cc18a66db32b524d;hb=3d344e21b632786c6c5ccc6c2bdaee07484a9fb6;hp=c64759ff57cb153690362a8dcc50b64b3969720c;hpb=0fbcef83aa6060534172bb13e71cdadb04428806;p=libfirm diff --git a/ir/opt/tailrec.c b/ir/opt/tailrec.c index c64759ff5..28ab28faa 100644 --- a/ir/opt/tailrec.c +++ b/ir/opt/tailrec.c @@ -304,9 +304,9 @@ static void do_opt_tail_rec(ir_graph *irg, tr_env *env) { modes[i] = mode; if (env->variants[i] == TR_ADD) { - set_value(i, new_Const(mode, get_mode_null(mode))); + set_value(i, new_Const(get_mode_null(mode))); } else if (env->variants[i] == TR_MUL) { - set_value(i, new_Const(mode, get_mode_one(mode))); + set_value(i, new_Const(get_mode_one(mode))); } } mature_immBlock(start_block); @@ -417,23 +417,24 @@ static void do_opt_tail_rec(ir_graph *irg, tr_env *env) { * @return non-zero if it's ok to do tail recursion */ static int check_lifetime_of_locals(ir_graph *irg) { - ir_node *irg_frame, *irg_val_param_base; + ir_node *irg_frame; int i; + ir_type *frame_tp = get_irg_frame_type(irg); irg_frame = get_irg_frame(irg); for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) { ir_node *succ = get_irn_out(irg_frame, i); - if (is_Sel(succ) && is_address_taken(succ)) - return 0; - } - - /* Check if we have compound arguments. - For now, we cannot handle them, */ - irg_val_param_base = get_irg_value_param_base(irg); - if (get_irn_n_outs(irg_val_param_base) > 0) - return 0; + if (is_Sel(succ)) { + /* Check if we have compound arguments. + For now, we cannot handle them, */ + if (get_entity_owner(get_Sel_entity(succ)) != frame_tp) + return 0; + if (is_address_taken(succ)) + return 0; + } + } return 1; }