Very cheap and quite effective since tail return is common.
Please test.

Should apply to all archs, but then arch-depenendent size
of jump instruction needs #defining.

Index: tcc.c
===================================================================
RCS file: /cvsroot/tinycc/tinycc/tcc.c,v
retrieving revision 1.179
diff -u -b -B -w -p -r1.179 tcc.c
--- tcc.c       3 Sep 2005 22:51:34 -0000       1.179
+++ tcc.c       3 Oct 2005 14:23:58 -0000
@@ -8926,6 +8926,13 @@ static void gen_function(Sym *sym)
     gfunc_prolog(&sym->type);
     rsym = 0;
     block(NULL, NULL, NULL, NULL, 0, 0);
+#ifdef TCC_TARGET_I386
+    if (rsym == ind - 4) {
+        /* kill the final jump to the epilog */
+        rsym = *(int*)(cur_text_section->data + rsym);
+        ind -= 5;
+    }
+#endif
     gsym(rsym);
     gfunc_epilog();
     cur_text_section->data_offset = ind;

--
Zdenek Pavlas


_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to