public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7458] calls: When bypassing emit_push_insn for 0 sized arg, emit at least anti_adjust_stack for alignment
@ 2022-03-03 8:12 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-03-03 8:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e6e6e0a97340068c90fe091482efbaacd6474754
commit r12-7458-ge6e6e0a97340068c90fe091482efbaacd6474754
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Mar 3 09:11:09 2022 +0100
calls: When bypassing emit_push_insn for 0 sized arg, emit at least anti_adjust_stack for alignment pad if needed [PR104558]
The following testcase ICEs on x86_64 when asked to use the pre-GCC 8
ABI where zero sized arguments weren't ignored.
In GCC 7 the emit_push_insn calls in store_one_arg were unconditional,
it is true that they didn't actually push anything because it had zero
size, but because arg->locate.alignment_pad is 8 in this case,
emit_push_insn at the end performs
if (alignment_pad && args_addr == 0)
anti_adjust_stack (alignment_pad);
and an assert larger on is upset if we don't do it.
The following patch keeps the emit_push_insn conditional but calls
the anti_adjust_stack when needed by hand for the zero sized arguments.
For the new x86_64 ABI where zero sized arguments are ignored
arg->locate.alignment_pad is 0 in this case, so nothing changes
- we in that case really do ignore it.
There is another emit_push_insn call earlier in store_one_arg, also made
conditional on non-zero size by Marek in GCC 8, but that one is for
arguments with non-BLKmode and the only way those can be zero size is
if they are TYPE_EMPTY_P aka when they are completely ignored. But
I believe arg->locate.alignment_pad should be 0 in that case, so IMHO
there is no need to do anything in the second spot.
2022-03-03 Jakub Jelinek <jakub@redhat.com>
PR middle-end/104558
* calls.cc (store_one_arg): When not calling emit_push_insn
because size_rtx is const0_rtx, call at least anti_adjust_stack
on arg->locate.alignment_pad if !argblock and the alignment might
be non-zero.
* gcc.dg/pr104558.c: New test.
Diff:
---
gcc/calls.cc | 7 +++++++
gcc/testsuite/gcc.dg/pr104558.c | 15 +++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/gcc/calls.cc b/gcc/calls.cc
index e64a937ea33..58864d0fdb3 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -5139,6 +5139,13 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags,
ARGS_SIZE_RTX (arg->locate.offset),
reg_parm_stack_space,
ARGS_SIZE_RTX (arg->locate.alignment_pad), false);
+ /* If we bypass emit_push_insn because it is a zero sized argument,
+ we still might need to adjust stack if such argument requires
+ extra alignment. See PR104558. */
+ else if ((arg->locate.alignment_pad.var
+ || maybe_ne (arg->locate.alignment_pad.constant, 0))
+ && !argblock)
+ anti_adjust_stack (ARGS_SIZE_RTX (arg->locate.alignment_pad));
/* Unless this is a partially-in-register argument, the argument is now
in the stack.
diff --git a/gcc/testsuite/gcc.dg/pr104558.c b/gcc/testsuite/gcc.dg/pr104558.c
new file mode 100644
index 00000000000..382fe5732d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr104558.c
@@ -0,0 +1,15 @@
+/* PR middle-end/104558 */
+/* { dg-do compile } */
+/* { dg-options "-fabi-version=9" } */
+
+struct __attribute__ ((aligned)) A {};
+
+struct A a;
+
+void bar (int, int, int, int, int, int, int, struct A);
+
+void
+foo (void)
+{
+ bar (0, 1, 2, 3, 4, 5, 6, a);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-03 8:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 8:12 [gcc r12-7458] calls: When bypassing emit_push_insn for 0 sized arg, emit at least anti_adjust_stack for alignment Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).