diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-15 14:41:10 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-15 14:41:10 +0000 |
commit | d94a1f53475290eb1725ee2456c2785c1d07a49c (patch) | |
tree | fa57a9eddd888c9241714cfcc44471d4d36211f8 /gcc/calls.c | |
parent | 607320fcd40aa6783478d8aed97ff891f3313ea0 (diff) | |
download | gcc-d94a1f53475290eb1725ee2456c2785c1d07a49c.tar.gz |
PR 69246: Invalid REG_ARGS_SIZE for sibcalls
The problem in this PR was that we were treating a sibcall as popping
arguments, leading to a negative REG_ARGS_SIZE.
It doesn't really make sense to treat sibcalls as popping since
(a) they're deallocating the caller's stack, not ours, and
(b) there are no optabs for popping sibcalls (any more).
Tested on x86_64-linux-gnu.
gcc/
PR middle-end/69246
* calls.c (emit_call_1): Force n_popped to zero for sibcalls.
gcc/testsuite/
PR middle-end/69246
* gcc.target/i386/pr69246.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232428 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/calls.c')
-rw-r--r-- | gcc/calls.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/calls.c b/gcc/calls.c index a1549348b52..8f573b83430 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -272,12 +272,19 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU rtx rounded_stack_size_rtx = GEN_INT (rounded_stack_size); rtx call, funmem, pat; int already_popped = 0; - HOST_WIDE_INT n_popped - = targetm.calls.return_pops_args (fndecl, funtype, stack_size); + HOST_WIDE_INT n_popped = 0; + + /* Sibling call patterns never pop arguments (no sibcall(_value)_pop + patterns exist). Any popping that the callee does on return will + be from our caller's frame rather than ours. */ + if (!(ecf_flags & ECF_SIBCALL)) + { + n_popped += targetm.calls.return_pops_args (fndecl, funtype, stack_size); #ifdef CALL_POPS_ARGS - n_popped += CALL_POPS_ARGS (*get_cumulative_args (args_so_far)); + n_popped += CALL_POPS_ARGS (*get_cumulative_args (args_so_far)); #endif + } /* Ensure address is valid. SYMBOL_REF is already valid, so no need, and we don't want to load it into a register as an optimization, |