]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sibcall: Check partial != 0 for BLKmode argument
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 12 Oct 2024 20:53:14 +0000 (04:53 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 25 Nov 2024 21:48:45 +0000 (05:48 +0800)
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>
gcc/calls.cc
gcc/testsuite/gcc.dg/sibcall-12.c [new file with mode: 0644]

index 648889662c7c34c0f576746bc5323aead666e48c..8cf0f29b42c3282657afeb580e8544ec89477bac 100644 (file)
@@ -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 (file)
index 0000000..5773c9c
--- /dev/null
@@ -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);
+}