X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ftailrec.c;h=7666bd8224b8b894ec832620b325cb70aaa7e376;hb=8df5c7fd80e2ecfb8bb896b426cf47335deb7bdf;hp=de1940847903ee29c38cb1de30c3e8d3392dde26;hpb=6c176d4b23f0a13b29edfd203a1072eb1751a1db;p=libfirm diff --git a/ir/opt/tailrec.c b/ir/opt/tailrec.c index de1940847..7666bd822 100644 --- a/ir/opt/tailrec.c +++ b/ir/opt/tailrec.c @@ -267,6 +267,7 @@ int opt_tail_rec_irg(ir_graph *irg) int n_preds; int i, n_tail_calls = 0; ir_node *rets = NULL; + type *mtd_type, *call_type; if (! get_opt_tail_recursion() || ! get_opt_optimize()) return 0; @@ -325,6 +326,27 @@ int opt_tail_rec_irg(ir_graph *irg) if (j < n_ress) continue; + /* + * Check, that the types match. At least in C + * this might fail. + */ + mtd_type = get_entity_type(ent); + call_type = get_Call_type(call); + + if (mtd_type != call_type) { + /* + * Hmm, the types did not match, bad. + * This can happen in C when no prototyp is given + * or K&R style is used. + */ +#if 0 + printf("Warning: Tail recursion fails because of different method and call types:\n"); + dump_type(mtd_type); + dump_type(call_type); +#endif + return 0; + } + /* here, we have found a call */ set_irn_link(call, get_irn_link(end_block)); set_irn_link(end_block, call);