From 6312165650091a4df34668d8e2aaa0bbc4008a66 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 28 Jan 2025 14:57:21 +0100 Subject: [PATCH] GCN, nvptx: 'sorry, unimplemented: exception handling not supported' For GCN, this avoids ICEs further down the compilation pipeline. For nvptx, there's effectively no change: in presence of exception handling constructs, instead of 'sorry, unimplemented: target cannot support nonlocal goto', we now emit 'sorry, unimplemented: exception handling not supported'. Additionally, turn test cases into UNSUPPORTED if running into 'sorry, unimplemented: exception handling not supported'. gcc/ * config/gcn/gcn.md (exception_receiver): 'define_expand'. * config/nvptx/nvptx.md (exception_receiver): Likewise. gcc/testsuite/ * lib/gcc-dg.exp (gcc-dg-prune): Turn 'sorry, unimplemented: exception handling not supported' into UNSUPPORTED. * gcc.dg/pr104464.c: Remove GCN XFAIL. libstdc++-v3/ * testsuite/lib/prune.exp (libstdc++-dg-prune): Turn 'sorry, unimplemented: exception handling not supported' into UNSUPPORTED. --- gcc/config/gcn/gcn.md | 7 +++++++ gcc/config/nvptx/nvptx.md | 7 +++++++ gcc/testsuite/gcc.dg/pr104464.c | 2 -- gcc/testsuite/lib/gcc-dg.exp | 7 +++++++ libstdc++-v3/testsuite/lib/prune.exp | 7 +++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 9dddfca742b..695656f692d 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1014,6 +1014,13 @@ [(set_attr "type" "sopp") (set_attr "length" "4")]) +(define_expand "exception_receiver" + [(const_int 0)] + "" +{ + sorry ("exception handling not supported"); +}) + ;; }}} ;; {{{ Conditionals diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index a22a088fb3a..d3d538070c0 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -1640,6 +1640,13 @@ DONE; }) +(define_expand "exception_receiver" + [(const_int 0)] + "" +{ + sorry ("exception handling not supported"); +}) + (define_expand "nonlocal_goto" [(match_operand 0 "" "") (match_operand 1 "" "") diff --git a/gcc/testsuite/gcc.dg/pr104464.c b/gcc/testsuite/gcc.dg/pr104464.c index d36a28678cb..ed6a22c39d5 100644 --- a/gcc/testsuite/gcc.dg/pr104464.c +++ b/gcc/testsuite/gcc.dg/pr104464.c @@ -9,5 +9,3 @@ foo(void) { f += (F)(f != (F){}[0]); } - -/* { dg-xfail-if "-fnon-call-exceptions unsupported" { amdgcn-*-* } } */ diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 07a996a4466..70be7a8d5fd 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -434,6 +434,13 @@ proc gcc-dg-prune { system text } { return "::unsupported::large return values" } + # If exception handling is not supported, expectant tests are UNSUPPORTED. + if { ![check_effective_target_exceptions] } { + if [regexp "(^|\n)\[^\n\]*: sorry, unimplemented: exception handling not supported" $text] { + return "::unsupported::exception handling not supported" + } + } + # If exception handling is disabled, expectant tests are UNSUPPORTED. if { ![check_effective_target_exceptions_enabled] } { if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] { diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp index 593b74985fb..566572baa6d 100644 --- a/libstdc++-v3/testsuite/lib/prune.exp +++ b/libstdc++-v3/testsuite/lib/prune.exp @@ -89,6 +89,13 @@ proc libstdc++-dg-prune { system text } { # the single uncapitalized "in function" line. regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text + # If exception handling is not supported, expectant tests are UNSUPPORTED. + if { ![check_effective_target_exceptions] } { + if [regexp "(^|\n)\[^\n\]*: sorry, unimplemented: exception handling not supported" $text] { + return "::unsupported::exception handling not supported" + } + } + # If exception handling is disabled, expectant tests are UNSUPPORTED. if { ![check_effective_target_exceptions_enabled] } { if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] {