]> git.ipfire.org Git - thirdparty/gcc.git/commit
GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]
authorThomas Schwinge <tschwinge@baylibre.com>
Fri, 28 Mar 2025 08:20:49 +0000 (09:20 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Mon, 14 Apr 2025 21:56:05 +0000 (23:56 +0200)
commitfe283dba774be57b705a7a871b000d2894d2e553
treeb198006707a111b82ea2745e494c970d585ba89c
parent6c0ea840265454b01d9ef4eb8850a4f015788788
GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]

With '-mfake-exceptions' enabled, the user-visible behavior in presence of
exception handling constructs changes such that the compile-time
'sorry, unimplemented: exception handling not supported' is skipped, code
generation proceeds, and instead, exception handling constructs 'abort' at
run time.  (..., or don't, if they're in dead code.)

PR target/118794
gcc/
* config/gcn/gcn.opt (-mfake-exceptions): Support.
* config/nvptx/nvptx.opt (-mfake-exceptions): Likewise.
* config/gcn/gcn.md (define_expand "exception_receiver"): Use it.
* config/nvptx/nvptx.md (define_expand "exception_receiver"):
Likewise.
* config/gcn/mkoffload.cc (main): Set it.
* config/nvptx/mkoffload.cc (main): Likewise.
* config/nvptx/nvptx.cc (nvptx_assemble_integer)
<in_section == exception_section>: Special handling for
'SYMBOL_REF's.
* except.cc (expand_dw2_landing_pad_for_region): Don't generate
bogus code for (default)
'#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'.
libgcc/
* config/gcn/unwind-gcn.c (_Unwind_Resume): New.
* config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise.
gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-2.C: Set
'-mno-fake-exceptions'.
* g++.target/gcn/exceptions-pr118794-1.C: Likewise.
* g++.target/gcn/exceptions-throw-2.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
* g++.target/nvptx/exceptions-throw-2.C: Likewise.
* g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New.
* g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C:
Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C:
Set '-foffload-options=-mno-fake-exceptions'.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust.
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.
38 files changed:
gcc/config/gcn/gcn.md
gcc/config/gcn/gcn.opt
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
gcc/config/nvptx/nvptx.cc
gcc/config/nvptx/nvptx.md
gcc/config/nvptx/nvptx.opt
gcc/except.cc
gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C
gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C [new file with mode: 0644]
gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
gcc/testsuite/g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C [new file with mode: 0644]
gcc/testsuite/g++.target/gcn/exceptions-throw-2.C
gcc/testsuite/g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C [new file with mode: 0644]
gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C
gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C [new file with mode: 0644]
gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C [new file with mode: 0644]
gcc/testsuite/g++.target/nvptx/exceptions-throw-2.C
gcc/testsuite/g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C [new file with mode: 0644]
libgcc/config/gcn/unwind-gcn.c
libgcc/config/nvptx/unwind-nvptx.c
libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C
libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C
libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C
libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C
libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C
libgomp/testsuite/libgomp.c++/target-exceptions-throw-2-O0.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C
libgomp/testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C
libgomp/testsuite/libgomp.c++/target-exceptions-throw-2.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C
libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C