projects
/
libfirm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
24ca4ec
)
Check call type and method type before doing tail recursion.
author
Michael Beck
<beck@ipd.info.uni-karlsruhe.de>
Wed, 13 Apr 2005 10:40:40 +0000
(10:40 +0000)
committer
Michael Beck
<beck@ipd.info.uni-karlsruhe.de>
Wed, 13 Apr 2005 10:40:40 +0000
(10:40 +0000)
[r5683]
ir/opt/tailrec.c
patch
|
blob
|
history
diff --git
a/ir/opt/tailrec.c
b/ir/opt/tailrec.c
index
de19408
..
7666bd8
100644
(file)
--- 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;
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;
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;
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);
/* here, we have found a call */
set_irn_link(call, get_irn_link(end_block));
set_irn_link(end_block, call);