Sorry, I posted the patch with the wrong subject (from an earlier
version of the patch), and with a filename typo in the ChangeLog.
Here's a corrected version.
On powerpc-elf, a number of musttail tests fail because of passing
structs as arguments. They require caller copying.
The struct_musttail effective target, that checks for support for
returning structs, isn't enough to cover these uses, so I'm adding
struct_parm_musttail. It's undocumented in the manual, like the other
musttail effective targets. There doesn't seem to be a subsubsection
where they'd fit.
Regstrapped on x86_64-linux-gnu, regstrapping on powerpc64le-linux-gnu,
also tested with gcc-15 targeting powerpc-elf. Ok to install?
for gcc/testsuite/ChangeLog
* c-c++-common/musttail32.c: Require struct_parm_musttail.
* g++.dg/opt/musttail2.C: Likewise.
* g++.dg/opt/musttail3.C: Likewise.
* g++.dg/opt/musttail5.C: Likewise.
* g++.dg/opt/pr119613.C: Likewise.
* lib/target-supports.exp
(check_effective_target_struct_parm_musttail): New.
---
gcc/testsuite/c-c++-common/musttail32.c | 2 +-
gcc/testsuite/g++.dg/opt/musttail2.C | 2 +-
gcc/testsuite/g++.dg/opt/musttail3.C | 2 +-
gcc/testsuite/g++.dg/opt/musttail5.C | 2 +-
gcc/testsuite/g++.dg/opt/pr119613.C | 2 +-
gcc/testsuite/lib/target-supports.exp | 10 ++++++++++
6 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/gcc/testsuite/c-c++-common/musttail32.c
b/gcc/testsuite/c-c++-common/musttail32.c
index f1b7052fe906c..0b0fbbd030c9f 100644
--- a/gcc/testsuite/c-c++-common/musttail32.c
+++ b/gcc/testsuite/c-c++-common/musttail32.c
@@ -1,5 +1,5 @@
/* PR ipa/121023 */
-/* { dg-do compile { target musttail } } */
+/* { dg-do compile { target struct_parm_musttail } } */
/* { dg-options "-O2" } */
struct S { int a, b; };
diff --git a/gcc/testsuite/g++.dg/opt/musttail2.C
b/gcc/testsuite/g++.dg/opt/musttail2.C
index d12fcb2e397d7..e4082e6858f38 100644
--- a/gcc/testsuite/g++.dg/opt/musttail2.C
+++ b/gcc/testsuite/g++.dg/opt/musttail2.C
@@ -1,5 +1,5 @@
// PR ipa/119376
-// { dg-do compile { target musttail } }
+// { dg-do compile { target struct_parm_musttail } }
// { dg-options "-O2 -fno-early-inlining -fdump-tree-optimized" }
// { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\);
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } }
diff --git a/gcc/testsuite/g++.dg/opt/musttail3.C
b/gcc/testsuite/g++.dg/opt/musttail3.C
index a2db4479ec17e..06f6e903e145e 100644
--- a/gcc/testsuite/g++.dg/opt/musttail3.C
+++ b/gcc/testsuite/g++.dg/opt/musttail3.C
@@ -1,5 +1,5 @@
// PR tree-optimization/119491
-// { dg-do compile { target { external_musttail && { c++11 && { !
using_sjlj_exceptions } } } } }
+// { dg-do compile { target { { external_musttail && struct_parm_musttail } &&
{ c++11 && { ! using_sjlj_exceptions } } } } }
// { dg-options "-O2" }
struct A {
diff --git a/gcc/testsuite/g++.dg/opt/musttail5.C
b/gcc/testsuite/g++.dg/opt/musttail5.C
index 10e8d940dbb60..0ff1cec9d035c 100644
--- a/gcc/testsuite/g++.dg/opt/musttail5.C
+++ b/gcc/testsuite/g++.dg/opt/musttail5.C
@@ -1,5 +1,5 @@
// PR tree-optimization/119491
-// { dg-do compile { target { external_musttail && { c++11 && { !
using_sjlj_exceptions } } } } }
+// { dg-do compile { target { { external_musttail && struct_parm_musttail } &&
{ c++11 && { ! using_sjlj_exceptions } } } } }
// { dg-options "-O2" }
struct A {
diff --git a/gcc/testsuite/g++.dg/opt/pr119613.C
b/gcc/testsuite/g++.dg/opt/pr119613.C
index c3657eb4f984c..fe3da02bacad2 100644
--- a/gcc/testsuite/g++.dg/opt/pr119613.C
+++ b/gcc/testsuite/g++.dg/opt/pr119613.C
@@ -1,5 +1,5 @@
// PR middle-end/119613
-// { dg-do compile { target { musttail && { c++11 && { ! using_sjlj_exceptions
} } } } }
+// { dg-do compile { target { struct_parm_musttail && { c++11 && { !
using_sjlj_exceptions } } } } }
// { dg-options "-O0" }
struct S { S () {} };
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index 49fe3052e530e..cc3f8a74d9b05 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -13694,6 +13694,16 @@ proc check_effective_target_struct_musttail { } {
} {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
}
+# Return 1 if the target can perform musttail optimizations for
+# structures passed as arguments. powerpc-elf for one can't.
+proc check_effective_target_struct_parm_musttail { } {
+ return [check_no_messages_and_pattern struct_parm_musttail ",SIBCALL"
rtl-expand {
+ struct foo { int a, b; };
+ extern __attribute__((__noipa__)) int foo (struct foo bar);
+ __attribute__((__noipa__)) int bar (struct foo bar) { [[gnu::musttail]]
return foo(bar); }
+ } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
+}
+
# Return 1 if the target's calling sequence or its ABI
# create implicit stack probes at or prior to function entry.
proc check_effective_target_caller_implicit_probes { } {
--
Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
Free Software Activist FSFLA co-founder GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!