]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR116080: Fix test suite checks for musttail
authorAndi Kleen <ak@gcc.gnu.org>
Mon, 29 Jul 2024 17:58:29 +0000 (10:58 -0700)
committerAndi Kleen <ak@gcc.gnu.org>
Tue, 3 Sep 2024 19:59:27 +0000 (12:59 -0700)
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.

12 files changed:
gcc/testsuite/c-c++-common/musttail1.c
gcc/testsuite/c-c++-common/musttail12.c
gcc/testsuite/c-c++-common/musttail2.c
gcc/testsuite/c-c++-common/musttail3.c
gcc/testsuite/c-c++-common/musttail4.c
gcc/testsuite/c-c++-common/musttail7.c
gcc/testsuite/c-c++-common/musttail8.c
gcc/testsuite/g++.dg/musttail10.C
gcc/testsuite/g++.dg/musttail11.C
gcc/testsuite/g++.dg/musttail6.C
gcc/testsuite/g++.dg/musttail9.C
gcc/testsuite/lib/target-supports.exp

index 74efcc2a0bc6b45efd832f1c9b1743a964ebb6a6..51549672e02a62d0632359c1ae324f02fe37426f 100644 (file)
@@ -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))
index 4140bcd00950c451969e1ed754423094da6a50d5..475afc5af3f31dffc3b27e1ebb4d2ceffa14f9bf 100644 (file)
@@ -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
index 86f2c3d7740484cfd68b857ad9593cc794f1e409..1970c4edd670e5aa8f8f53bc3af522e4ab965d41 100644 (file)
@@ -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; };
 
index ea9589c59ef23e2d814c4debf235178f03da71d9..7499fd6460b47c329f40bde11e9bca644c6219e5 100644 (file)
@@ -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, ...);
 
index 23f4b5e1cd68475eb09e6b3030fbb89bec20c4c2..bd6effa4b9314eea8dfde661dd7fa22748fa8dbe 100644 (file)
@@ -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; };
 
index c753a3fe9b2a70e9df7ebc712288294d88af6211..d17cb71256d770b906121a75a3357070803a62af 100644 (file)
@@ -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() {}
index 9fa10e0b54c42fc40d8036ba0aaa488119a8ccdb..50ca1ac0dd48b29e053c7d49bf2f2f5a8f5f4dea 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-do compile { target { musttail && { c || c++11 } } } } */
 
 float f1(void);
 
index ff7fcc7d8755ae879c45c7d56361144fe3232091..a43d8a6fde7e8f017a93937fa4ce09c0ab0aa779 100644 (file)
@@ -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))
index 1779e3287a93465a92c6ebd4bc0a4bc42b2a3bab..dca87247d5046ffa0eacef91f88eb1a5536ca471 100644 (file)
@@ -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*-*-* } } */
 
index 5c6f69407ddb6ee1d58d93116317a633e937ecb2..5dcf302139ae5d7387befd29f158e07b3a023d8b 100644 (file)
@@ -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*-*-* } } */
 
index fb0262e751becd37960dcbfe3f084224bfcf148d..85937dcdcd31661e319da035f4b381c3e282d4f3 100644 (file)
@@ -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*-*-* } } */
 
index d3569c80b6fed3b62a34a8dd501394c56bbb2440..d537d3055b34387b26433f2a3bf5a3ef4cda99b7 100644 (file)
@@ -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