]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add require target for SJLJ exception implementation
authorDimitar Dimitrov <dimitar@dinux.eu>
Sat, 18 Jan 2025 15:10:43 +0000 (17:10 +0200)
committerDimitar Dimitrov <dimitar@dinux.eu>
Fri, 25 Apr 2025 20:07:10 +0000 (23:07 +0300)
Testcases for musttail call optimization fail on pru-unknown-elf:
  FAIL: c-c++-common/musttail14.c  -std=gnu++17 (test for excess errors)
  Excess errors:
  .../gcc/gcc/testsuite/c-c++-common/musttail14.c:37:14: error: cannot tail-call: caller uses sjlj exceptions

Silence these errors by disabling the tests if target uses SJLJ for
implementing exceptions.  Use a new effective target check for this.

Ensured that test results with and without this patch for
x86_64-pc-linux-gnu are the same.

gcc/ChangeLog:

* doc/sourcebuild.texi: Document effective target
using_sjlj_exceptions.

gcc/testsuite/ChangeLog:

* c-c++-common/musttail14.c: Disable test if effective target
using_sjlj_exceptions.
* c-c++-common/musttail22.c: Ditto.
* g++.dg/musttail8.C: Ditto.
* g++.dg/musttail9.C: Ditto.
* g++.dg/opt/musttail3.C: Ditto.
* g++.dg/opt/musttail4.C: Ditto.
* g++.dg/opt/musttail5.C: Ditto.
* g++.dg/opt/pr119613.C: Ditto.
* lib/target-supports.exp
(check_effective_target_using_sjlj_exceptions): New check.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
gcc/doc/sourcebuild.texi
gcc/testsuite/c-c++-common/musttail14.c
gcc/testsuite/c-c++-common/musttail22.c
gcc/testsuite/g++.dg/musttail8.C
gcc/testsuite/g++.dg/musttail9.C
gcc/testsuite/g++.dg/opt/musttail3.C
gcc/testsuite/g++.dg/opt/musttail4.C
gcc/testsuite/g++.dg/opt/musttail5.C
gcc/testsuite/g++.dg/opt/pr119613.C
gcc/testsuite/lib/target-supports.exp

index c29cd3f5207e80f9530d26d9b2d429dd349a7dfa..0bd98737156239614b89cf1bafb1c6a7fb4b5d01 100644 (file)
@@ -3012,6 +3012,9 @@ Note that this is orthogonal to effective-target @code{exceptions_enabled}.
 Testing configuration has exception handling enabled.
 Note that this is orthogonal to effective-target @code{exceptions}.
 
+@item using_sjlj_exceptions
+Target uses @code{setjmp} and @code{longjmp} for implementing exceptions.
+
 @item fgraphite
 Target supports Graphite optimizations.
 
index 56a52b8638bd1646604469a1aafe35e45f51ba3b..5bda742b36f36fd486a18059ad71e52a143e20fc 100644 (file)
@@ -1,5 +1,5 @@
 /* PR tree-optimization/118430 */
-/* { dg-do compile { target musttail } } */
+/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */
 /* { dg-options "-O2 -fdump-tree-optimized" } */
 /* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "  \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
index eb812494f44d5d2a1f4bdc2fd34057e4e501b3b4..7dc0f199ea9277c1ea337031f8aa5422419e8f7f 100644 (file)
@@ -1,5 +1,5 @@
 /* PR tree-optimization/118430 */
-/* { dg-do compile { target musttail } } */
+/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */
 /* { dg-options "-O2 -fdump-tree-optimized" } */
 /* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "  \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
index 0f1b68bd2695eb7d158895dc7c5ed407a25e0758..18de9c87935d89d201d2c14e621baf94f87870d7 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { musttail } } } */
+/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */
 /* { dg-options "-std=gnu++11" } */
 /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
 
index 85937dcdcd31661e319da035f4b381c3e282d4f3..1c3a744a4e431c7f641cc276dcf405dc37156ad9 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { musttail } } } */
+/* { dg-do compile { target { musttail && { ! using_sjlj_exceptions } } } } */
 /* { dg-options "-std=gnu++11" } */
 /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
 
index 1c4e54952b1e41723bdb64534a5cac18fa23c012..a2db4479ec17ef54593d393e09b99451452ade01 100644 (file)
@@ -1,5 +1,5 @@
 // PR tree-optimization/119491
-// { dg-do compile { target { external_musttail && c++11 } } }
+// { dg-do compile { target { external_musttail && { c++11 && { ! using_sjlj_exceptions } } } } }
 // { dg-options "-O2" }
 
 struct A {
index ede2959f7d7428c2002f895507604bc3ed27a0fe..3362ccc5e01109ddcff8845f0f5953177dff7c00 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-do compile { target { external_musttail && c++11 } } }
+// { dg-do compile { target { external_musttail && { c++11 && { ! using_sjlj_exceptions } } } } }
 // { dg-options "-O2 -fexceptions" }
 
 struct S { ~S (); };
index 604dd6907aa9aa0cec0e8fac32a428b2fd61735a..10e8d940dbb6072466884dda232a74ec58ea07cb 100644 (file)
@@ -1,5 +1,5 @@
 // PR tree-optimization/119491
-// { dg-do compile { target { external_musttail && c++11 } } }
+// { dg-do compile { target { external_musttail && { c++11 && { ! using_sjlj_exceptions } } } } }
 // { dg-options "-O2" }
 
 struct A {
index 2ced2e8fa2a06b911f6ee235bf12bb158164fe01..c3657eb4f984c42a9cff650ea12730ee0846d632 100644 (file)
@@ -1,5 +1,5 @@
 // PR middle-end/119613
-// { dg-do compile { target { musttail && c++11 } } }
+// { dg-do compile { target { musttail && { c++11 && { ! using_sjlj_exceptions } } } } }
 // { dg-options "-O0" }
 
 struct S { S () {} };
index 869d1501c3836085eb6ebfc3f1f171490b8df9f1..16bb2ae442648142d568fd0c451a894faa011834 100644 (file)
@@ -12632,6 +12632,18 @@ proc check_effective_target_exceptions_enabled {} {
     }]
 }
 
+# Returns 1 if target uses setjump/longjump for implementing exceptions,
+# 0 otherwise.
+proc check_effective_target_using_sjlj_exceptions {} {
+    return [check_no_compiler_messages using_sjlj_exceptions assembly {
+       // C++
+       #if !defined __USING_SJLJ_EXCEPTIONS__
+       #error not using SJLJ exception implementation
+       #endif
+       int dummy;
+    }]
+}
+
 proc check_effective_target_tiny {} {
     return [check_cached_effective_target tiny {
       if { [istarget aarch64*-*-*]