This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix a pretend_args goof in tail calling
- From: Daniel Jacobowitz <drow at false dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Nov 2004 17:48:44 -0500
- Subject: Fix a pretend_args goof in tail calling
I noticed this problem in GCC 3.3, and it's still present. As far as I can
tell, the size of a function's incoming arguments area is
current_function_args_size - current_function_pretend_args_size; if we want
to put another function's arguments into our stack frame, they have to fit
there.
The test case caused a target with four-byte stack alignment to store one
word past the top of its stack frame, into the caller's. I couldn't get GCC
to put anything useful in the other half of the stack frame, though. The
ARM old-iWMMXt-ABI code showed other symptoms resulting from this, but that
ABI's no longer present in mainline to test.
Patch OK for HEAD?
--
Daniel Jacobowitz
2004-11-17 Daniel Jacobowitz <dan@codesourcery.com>
* calls.c (expand_call): Handle current_function_pretend_args_size
when checking for sibcalls.
--- gcc/gcc/calls.c.orig 2004-11-17 18:42:41.000000000 -0500
+++ gcc/gcc/calls.c 2004-11-17 18:42:35.000000000 -0500
@@ -2518,7 +2518,8 @@
|| !FUNCTION_OK_FOR_SIBCALL (fndecl)
/* If this function requires more stack slots than the current
function, we cannot change it into a sibling call. */
- || args_size.constant > current_function_args_size
+ || args_size.constant > (current_function_args_size
+ - current_function_pretend_args_size)
/* If the callee pops its own arguments, then it must pop exactly
the same number of arguments as the current function. */
|| (RETURN_POPS_ARGS (fndecl, funtype, args_size.constant)