https://gcc.gnu.org/g:62f8948456e1973bb79113af8943b7f23ebef228
commit 62f8948456e1973bb79113af8943b7f23ebef228 Author: Thomas Schwinge <tschwi...@baylibre.com> Date: Wed Apr 16 14:00:31 2025 +0200 For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106] PR target/97106 gcc/ * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls) [ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor aliases. libgomp/ * testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading. * testsuite/libgomp.c-c++-common/pr96390.c: Adjust. (cherry picked from commit ca9cffe737d20953082333dacebb65d4261e0d0c) Diff: --- gcc/ChangeLog.omp | 8 ++++++++ gcc/config/nvptx/nvptx.cc | 12 ++++++++++++ libgomp/ChangeLog.omp | 7 +++++++ libgomp/testsuite/libgomp.c++/pr96390.C | 2 -- libgomp/testsuite/libgomp.c-c++-common/pr96390.c | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 78f31903196e..6988afbd2388 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,5 +1,13 @@ 2025-04-17 Thomas Schwinge <tschwi...@baylibre.com> + Backported from trunk: + 2025-04-16 Thomas Schwinge <tschwi...@baylibre.com> + + PR target/97106 + * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls) + [ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor + aliases. + Backported from trunk: 2025-04-14 Thomas Schwinge <tschwi...@baylibre.com> diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index b8116e83c5f1..2c29091bfc19 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -8518,6 +8518,18 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, #endif cgraph_node *cnode = cgraph_node::get (name); +#ifdef ACCEL_COMPILER + /* For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106] + + For some reason (yet to be analyzed), they're not 'cnode->referred_to_p ()'. + (..., or that's not the right approach at all; + <https://inbox.sourceware.org/87v7rx8lbx....@euler.schwinge.ddns.net> + "Re: [committed][nvptx] Use .alias directive for mptx >= 6.3"). */ + if (DECL_CXX_CONSTRUCTOR_P (name) + || DECL_CXX_DESTRUCTOR_P (name)) + ; + else +#endif if (!cnode->referred_to_p ()) /* Prevent "Internal error: reference to deleted section". */ return; diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 967664b183bd..5343b9bbecc2 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,12 @@ 2025-04-17 Thomas Schwinge <tschwi...@baylibre.com> + Backported from trunk: + 2025-04-16 Thomas Schwinge <tschwi...@baylibre.com> + + PR target/97106 + * testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading. + * testsuite/libgomp.c-c++-common/pr96390.c: Adjust. + Backported from trunk: 2025-04-14 Thomas Schwinge <tschwi...@baylibre.com> diff --git a/libgomp/testsuite/libgomp.c++/pr96390.C b/libgomp/testsuite/libgomp.c++/pr96390.C index 1f3c3e056618..be1960186eaa 100644 --- a/libgomp/testsuite/libgomp.c++/pr96390.C +++ b/libgomp/testsuite/libgomp.c++/pr96390.C @@ -1,6 +1,4 @@ /* { dg-additional-options "-O0 -fdump-tree-omplower" } */ -/* { dg-additional-options "-foffload=-Wa,--verify" { target offload_target_nvptx } } */ -/* { dg-xfail-if "PR 97106/PR 97102 - .alias not (yet) supported for nvptx" { offload_target_nvptx } } */ #include <cstdlib> #include <type_traits> diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr96390.c b/libgomp/testsuite/libgomp.c-c++-common/pr96390.c index b89f934811a5..ca7865d322df 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/pr96390.c +++ b/libgomp/testsuite/libgomp.c-c++-common/pr96390.c @@ -1,7 +1,7 @@ /* { dg-additional-options "-O0 -fdump-tree-omplower" } */ /* { dg-additional-options "-foffload=-Wa,--verify" { target offload_target_nvptx } } */ /* { dg-require-alias "" } */ -/* { dg-xfail-if "PR 97102/PR 97106 - .alias not (yet) supported for nvptx" { offload_target_nvptx } } */ +/* { dg-xfail-if PR105018 { offload_target_nvptx } } */ #ifdef __cplusplus extern "C" {