aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Kleen <ak@gcc.gnu.org>2024-07-29 10:58:29 -0700
committerAndi Kleen <ak@gcc.gnu.org>2024-09-03 12:59:27 -0700
commit1fad396dd467326251572811b703e788e62a2588 (patch)
tree70aafed338b068a0f65216e8a775caa03d89a4f9
parent07e74798b93c256bea3a91895d3517223a58da61 (diff)
downloadgcc-1fad396dd467326251572811b703e788e62a2588.zip
gcc-1fad396dd467326251572811b703e788e62a2588.tar.gz
gcc-1fad396dd467326251572811b703e788e62a2588.tar.bz2
PR116080: Fix test suite checks for musttail
This is a new attempt to fix PR116080. The previous try was reverted because it just broke a bunch of tests, hiding the problem. - musttail behaves differently than tailcall at -O0. Some of the test run at -O0, so add separate effective target tests for musttail. - New effective target tests need to use unique file names to make dejagnu caching work - Change the tests to use new targets - Add a external_musttail test to check for target's ability to do tail calls between translation units. This covers some powerpc ABIs. gcc/testsuite/ChangeLog: PR testsuite/116080 * c-c++-common/musttail1.c: Use musttail target. * c-c++-common/musttail12.c: Use struct_musttail target. * c-c++-common/musttail2.c: Use musttail target. * c-c++-common/musttail3.c: Likewise. * c-c++-common/musttail4.c: Likewise. * c-c++-common/musttail7.c: Likewise. * c-c++-common/musttail8.c: Likewise. * g++.dg/musttail10.C: Likewise. Replace powerpc checks with external_musttail. * g++.dg/musttail11.C: Use musttail target. * g++.dg/musttail6.C: Use musttail target. Replace powerpc checks with external_musttail. * g++.dg/musttail9.C: Use musttail target. * lib/target-supports.exp: Add musttail, struct_musttail, external_musttail targets. Remove optimization for musttail. Use unique file names for musttail.
-rw-r--r--gcc/testsuite/c-c++-common/musttail1.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail12.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail2.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail3.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail4.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail7.c2
-rw-r--r--gcc/testsuite/c-c++-common/musttail8.c2
-rw-r--r--gcc/testsuite/g++.dg/musttail10.C6
-rw-r--r--gcc/testsuite/g++.dg/musttail11.C2
-rw-r--r--gcc/testsuite/g++.dg/musttail6.C4
-rw-r--r--gcc/testsuite/g++.dg/musttail9.C2
-rw-r--r--gcc/testsuite/lib/target-supports.exp30
12 files changed, 38 insertions, 20 deletions
diff --git a/gcc/testsuite/c-c++-common/musttail1.c b/gcc/testsuite/c-c++-common/musttail1.c
index 74efcc2..5154967 100644
--- a/gcc/testsuite/c-c++-common/musttail1.c
+++ b/gcc/testsuite/c-c++-common/musttail1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
int __attribute__((noinline,noclone,noipa))
diff --git a/gcc/testsuite/c-c++-common/musttail12.c b/gcc/testsuite/c-c++-common/musttail12.c
index 4140bcd..475afc5 100644
--- a/gcc/testsuite/c-c++-common/musttail12.c
+++ b/gcc/testsuite/c-c++-common/musttail12.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { struct_tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
struct str
diff --git a/gcc/testsuite/c-c++-common/musttail2.c b/gcc/testsuite/c-c++-common/musttail2.c
index 86f2c3d..1970c4e 100644
--- a/gcc/testsuite/c-c++-common/musttail2.c
+++ b/gcc/testsuite/c-c++-common/musttail2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
struct box { char field[256]; int i; };
diff --git a/gcc/testsuite/c-c++-common/musttail3.c b/gcc/testsuite/c-c++-common/musttail3.c
index ea9589c..7499fd6 100644
--- a/gcc/testsuite/c-c++-common/musttail3.c
+++ b/gcc/testsuite/c-c++-common/musttail3.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */
extern int foo2 (int x, ...);
diff --git a/gcc/testsuite/c-c++-common/musttail4.c b/gcc/testsuite/c-c++-common/musttail4.c
index 23f4b5e..bd6effa4 100644
--- a/gcc/testsuite/c-c++-common/musttail4.c
+++ b/gcc/testsuite/c-c++-common/musttail4.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
struct box { char field[64]; int i; };
diff --git a/gcc/testsuite/c-c++-common/musttail7.c b/gcc/testsuite/c-c++-common/musttail7.c
index c753a3f..d17cb71 100644
--- a/gcc/testsuite/c-c++-common/musttail7.c
+++ b/gcc/testsuite/c-c++-common/musttail7.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
void __attribute__((noipa)) f() {}
diff --git a/gcc/testsuite/c-c++-common/musttail8.c b/gcc/testsuite/c-c++-common/musttail8.c
index 9fa10e0..50ca1ac 100644
--- a/gcc/testsuite/c-c++-common/musttail8.c
+++ b/gcc/testsuite/c-c++-common/musttail8.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
float f1(void);
diff --git a/gcc/testsuite/g++.dg/musttail10.C b/gcc/testsuite/g++.dg/musttail10.C
index ff7fcc7..a43d8a6 100644
--- a/gcc/testsuite/g++.dg/musttail10.C
+++ b/gcc/testsuite/g++.dg/musttail10.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call } } } */
+/* { dg-do compile { target { musttail } } } */
/* { dg-options "-std=gnu++11" } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
@@ -8,11 +8,11 @@ double g() { [[gnu::musttail]] return f<int>(); } /* { dg-error "cannot tail-cal
template <class T>
__attribute__((noinline, noclone, noipa))
-T g1() { [[gnu::musttail]] return f<T>(); } /* { dg-error "target is not able" "" { target powerpc*-*-* } } */
+T g1() { [[gnu::musttail]] return f<T>(); } /* { dg-error "target is not able" "" { target { ! external_musttail } } } */
template <class T>
__attribute__((noinline, noclone, noipa))
-T g2() { [[gnu::musttail]] return f<T>(); }
+T g2() { [[gnu::musttail]] return f<T>(); } /* { dg-error "target is not able" "" { target { ! external_musttail } } } */
template <class T>
__attribute__((noinline, noclone, noipa))
diff --git a/gcc/testsuite/g++.dg/musttail11.C b/gcc/testsuite/g++.dg/musttail11.C
index 1779e32..dca8724 100644
--- a/gcc/testsuite/g++.dg/musttail11.C
+++ b/gcc/testsuite/g++.dg/musttail11.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call } } } */
+/* { dg-do compile { target { musttail } } } */
/* { dg-options "-std=gnu++11" } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
diff --git a/gcc/testsuite/g++.dg/musttail6.C b/gcc/testsuite/g++.dg/musttail6.C
index 5c6f694..5dcf302 100644
--- a/gcc/testsuite/g++.dg/musttail6.C
+++ b/gcc/testsuite/g++.dg/musttail6.C
@@ -1,6 +1,6 @@
-/* { dg-do compile { target { struct_tail_call } } } */
+/* { dg-do compile { target { struct_musttail } } } */
+/* { dg-require-effective-target external_musttail } */
/* A lot of architectures will not build this due to PR115606 and PR115607 */
-/* { dg-skip-if "powerpc does not support sibcall to templates" { powerpc*-*-* } } */
/* { dg-options "-std=gnu++11" } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
diff --git a/gcc/testsuite/g++.dg/musttail9.C b/gcc/testsuite/g++.dg/musttail9.C
index fb0262e..85937dc 100644
--- a/gcc/testsuite/g++.dg/musttail9.C
+++ b/gcc/testsuite/g++.dg/musttail9.C
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call } } } */
+/* { dg-do compile { target { musttail } } } */
/* { dg-options "-std=gnu++11" } */
/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index d3569c8..d537d30 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -12808,16 +12808,34 @@ proc check_effective_target_tail_call { } {
} {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
}
-# Return 1 if the target can perform tail-call optimizations for structures
+# Return 1 if the target can perform musttail optimizations of the
+# most trivial type. This is separate from tail_call because musttail
+# is supported at -O0.
+proc check_effective_target_musttail { } {
+ return [check_no_messages_and_pattern musttail ",SIBCALL" rtl-expand {
+ __attribute__((__noipa__)) void foo (void) { }
+ __attribute__((__noipa__)) void bar (void) { [[gnu::musttail]] return foo(); }
+ } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
+}
+
+# Return 1 if the target can perform musttail for externals
+proc check_effective_target_external_musttail { } {
+ return [check_no_messages_and_pattern external_musttail ",SIBCALL" rtl-expand {
+ extern __attribute__((__noipa__)) void foo (void);
+ __attribute__((__noipa__)) void bar (void) { [[gnu::musttail]] return foo(); }
+ } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
+}
+
+# Return 1 if the target can perform musttail optimizations for structures
# checking with C++ because the C++ compiler has less tail call ability
# due to PR115606 on some targets
-proc check_effective_target_struct_tail_call { } {
- return [check_no_messages_and_pattern tail_call ",SIBCALL" rtl-expand {
+proc check_effective_target_struct_musttail { } {
+ return [check_no_messages_and_pattern struct_musttail ",SIBCALL" rtl-expand {
// C++
struct foo { int a, b; };
- __attribute__((__noipa__)) struct foo foo (void) { return {}; }
- __attribute__((__noipa__)) struct foo bar (void) { return foo(); }
- } {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
+ extern __attribute__((__noipa__)) struct foo foo (void);
+ __attribute__((__noipa__)) struct foo bar (void) { [[gnu::musttail]] return foo(); }
+ } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump.
}
# Return 1 if the target's calling sequence or its ABI