https://gcc.gnu.org/g:ca9cffe737d20953082333dacebb65d4261e0d0c

commit r15-9523-gca9cffe737d20953082333dacebb65d4261e0d0c
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.

Diff:
---
 gcc/config/nvptx/nvptx.cc                        | 12 ++++++++++++
 libgomp/testsuite/libgomp.c++/pr96390.C          |  2 --
 libgomp/testsuite/libgomp.c-c++-common/pr96390.c |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 28da43ca740b..d1e25b99701c 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -7789,6 +7789,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/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" {

Reply via email to