diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-10-13 04:53:14 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-11-26 05:48:45 +0800 |
commit | c61576d89eb0fead37be39fcf0764bb915ea201f (patch) | |
tree | d0ee2eb64c542710f286355ecc8d6e82805507ab | |
parent | 22b13b1d4e3dce6bbc8792ffa08cefeb5e125a03 (diff) | |
download | gcc-c61576d89eb0fead37be39fcf0764bb915ea201f.zip gcc-c61576d89eb0fead37be39fcf0764bb915ea201f.tar.gz gcc-c61576d89eb0fead37be39fcf0764bb915ea201f.tar.bz2 |
sibcall: Check partial != 0 for BLKmode argument
The outgoing stack slot size may be different from the BLKmode argument
size due to parameter alignment. Check partial != 0 for BLKmode argument
passed on stack.
gcc/
PR middle-end/117098
* calls.cc (store_one_arg): Check partial != 0 for BLKmode argument
passed on stack.
gcc/testsuite/
PR middle-end/117098
* gcc.dg/sibcall-12.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r-- | gcc/calls.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/sibcall-12.c | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/calls.cc b/gcc/calls.cc index 6488896..8cf0f29 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -5245,7 +5245,7 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, they aren't really at the same location. Check for this by making sure that the incoming size is the same as the outgoing size. */ - if (maybe_ne (arg->locate.size.constant, size_val)) + if (partial != 0) sibcall_failure = true; } else if (maybe_in_range_p (arg->locate.offset.constant, diff --git a/gcc/testsuite/gcc.dg/sibcall-12.c b/gcc/testsuite/gcc.dg/sibcall-12.c new file mode 100644 index 0000000..5773c9c --- /dev/null +++ b/gcc/testsuite/gcc.dg/sibcall-12.c @@ -0,0 +1,13 @@ +// Test for sibcall optimization with struct aligned on stack. +// { dg-options "-O2" } +// { dg-final { scan-assembler "jmp" { target i?86-*-* x86_64-*-* } } } + +struct A { char a[17]; }; + +int baz (int a, int b, int c, void *p, struct A s, struct A); + +int +foo (int a, int b, int c, void *p, struct A s, struct A s2) +{ + return baz (a, b, c, p, s, s2); +} |