This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
sibcall vs setjmp
- To: gcc-patches at gcc dot gnu dot org
- Subject: sibcall vs setjmp
- From: Richard Henderson <rth at redhat dot com>
- Date: Mon, 4 Jun 2001 13:29:41 -0700
David Mosberger found a case involving setjmp where we'd apply the
tail-call optimization in a function that calls setjmp. If we longjmp
from the function to which we tail-called, the frame recorded by
setjmp is no longer valid.
At the moment I don't have a test case in a form appropriate for
the test suite.
Applied to mainline and branch.
r~
* sibcall.c (optimize_sibling_and_tail_recursive_call): Suppress
optimization if current_function_calls_setjmp.
Index: sibcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sibcall.c,v
retrieving revision 1.10.4.1
diff -c -p -d -r1.10.4.1 sibcall.c
*** sibcall.c 2001/05/12 20:59:51 1.10.4.1
--- sibcall.c 2001/06/04 20:25:22
*************** optimize_sibling_and_tail_recursive_call
*** 543,548 ****
--- 543,554 ----
if (frame_offset)
goto failure;
+ /* Any function that calls setjmp might have longjmp called from
+ any called function. ??? We really should represent this
+ properly in the CFG so that this needn't be special cased. */
+ if (current_function_calls_setjmp)
+ goto failure;
+
/* Taking the address of a local variable is fatal to tail
recursion if the address is used by the recursive call. */
if (current_function_uses_addressof)