From: Michael Beck Date: Wed, 13 Apr 2005 10:40:40 +0000 (+0000) Subject: Check call type and method type before doing tail recursion. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=ec02f60f3decb373023d411a2acf9222d5f5867f;p=libfirm Check call type and method type before doing tail recursion. [r5683] --- 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);