https://gcc.gnu.org/g:07b29ef00b7bbe985da62159306361faec2c3a20
commit r16-157-g07b29ef00b7bbe985da62159306361faec2c3a20 Author: Dimitar Dimitrov <dimi...@dinux.eu> Date: Sat Jan 18 17:10:43 2025 +0200 testsuite: Add require target for SJLJ exception implementation 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 <dimi...@dinux.eu> Diff: --- gcc/doc/sourcebuild.texi | 3 +++ gcc/testsuite/c-c++-common/musttail14.c | 2 +- gcc/testsuite/c-c++-common/musttail22.c | 2 +- gcc/testsuite/g++.dg/musttail8.C | 2 +- gcc/testsuite/g++.dg/musttail9.C | 2 +- gcc/testsuite/g++.dg/opt/musttail3.C | 2 +- gcc/testsuite/g++.dg/opt/musttail4.C | 2 +- gcc/testsuite/g++.dg/opt/musttail5.C | 2 +- gcc/testsuite/g++.dg/opt/pr119613.C | 2 +- gcc/testsuite/lib/target-supports.exp | 12 ++++++++++++ 10 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index c29cd3f5207e..0bd987371562 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -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. diff --git a/gcc/testsuite/c-c++-common/musttail14.c b/gcc/testsuite/c-c++-common/musttail14.c index 56a52b8638bd..5bda742b36f3 100644 --- a/gcc/testsuite/c-c++-common/musttail14.c +++ b/gcc/testsuite/c-c++-common/musttail14.c @@ -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" } } */ diff --git a/gcc/testsuite/c-c++-common/musttail22.c b/gcc/testsuite/c-c++-common/musttail22.c index eb812494f44d..7dc0f199ea92 100644 --- a/gcc/testsuite/c-c++-common/musttail22.c +++ b/gcc/testsuite/c-c++-common/musttail22.c @@ -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" } } */ diff --git a/gcc/testsuite/g++.dg/musttail8.C b/gcc/testsuite/g++.dg/musttail8.C index 0f1b68bd2695..18de9c87935d 100644 --- a/gcc/testsuite/g++.dg/musttail8.C +++ b/gcc/testsuite/g++.dg/musttail8.C @@ -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*-*-* } } */ diff --git a/gcc/testsuite/g++.dg/musttail9.C b/gcc/testsuite/g++.dg/musttail9.C index 85937dcdcd31..1c3a744a4e43 100644 --- a/gcc/testsuite/g++.dg/musttail9.C +++ b/gcc/testsuite/g++.dg/musttail9.C @@ -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*-*-* } } */ diff --git a/gcc/testsuite/g++.dg/opt/musttail3.C b/gcc/testsuite/g++.dg/opt/musttail3.C index 1c4e54952b1e..a2db4479ec17 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 } } } +// { dg-do compile { target { external_musttail && { c++11 && { ! using_sjlj_exceptions } } } } } // { dg-options "-O2" } struct A { diff --git a/gcc/testsuite/g++.dg/opt/musttail4.C b/gcc/testsuite/g++.dg/opt/musttail4.C index ede2959f7d74..3362ccc5e011 100644 --- a/gcc/testsuite/g++.dg/opt/musttail4.C +++ b/gcc/testsuite/g++.dg/opt/musttail4.C @@ -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 (); }; diff --git a/gcc/testsuite/g++.dg/opt/musttail5.C b/gcc/testsuite/g++.dg/opt/musttail5.C index 604dd6907aa9..10e8d940dbb6 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 } } } +// { dg-do compile { target { external_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 2ced2e8fa2a0..c3657eb4f984 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 } } } +// { dg-do compile { target { 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 869d1501c383..16bb2ae44264 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -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*-*-*]