public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-13] nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni'
@ 2023-05-19 16:51 Kwok Yeung
0 siblings, 0 replies; only message in thread
From: Kwok Yeung @ 2023-05-19 16:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:15507794a3706ecf6cb623c17cf96b2afc5a09c5
commit 15507794a3706ecf6cb623c17cf96b2afc5a09c5
Author: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon Dec 19 17:19:19 2022 +0100
nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni'
As I have reported to Nvidia in 2022-12-01 'NVIDIA Incident Report (3891704):
ptxas: Duplicate declaration error: "cannot be resolved by a '.static'"',
'ptxas' has an inscrutable error mode for duplicate declarations:
ptxas softstack-decl-1.o, line 11; error : '.extern' variable '__nvptx_stacks' cannot be resolved by a '.static'
ptxas fatal : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
ptxas uniform-simt-decl-1.o, line 12; error : '.extern' variable '__nvptx_uni' cannot be resolved by a '.static'
ptxas fatal : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
This is inscrutable, because (a) what is "cannot be resolved by a '.static'"
supposed to tell me (there is no '.static' in PTX?), and (b) why arent't
repeated declaration just verified to match the first, but otherwise a no-op
(like in other programming languages)?
gcc/
* config/nvptx/nvptx.cc (nvptx_assemble_undefined_decl): Notice
'__nvptx_stacks', '__nvptx_uni' declarations.
(nvptx_file_end): Don't emit duplicate declarations for those.
gcc/testsuite/
* gcc.target/nvptx/softstack-decl-1.c: Make 'dg-do assemble',
adjust.
* gcc.target/nvptx/uniform-simt-decl-1.c: Likewise.
Diff:
---
gcc/ChangeLog.omp | 4 ++++
gcc/config/nvptx/nvptx.cc | 14 ++++++++++++--
gcc/testsuite/ChangeLog.omp | 4 ++++
gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c | 8 ++++----
gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c | 8 ++++----
5 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index eefe99c8ff1..82083d6c988 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,9 @@
2023-01-20 Thomas Schwinge <thomas@codesourcery.com>
+ * config/nvptx/nvptx.cc (nvptx_assemble_undefined_decl): Notice
+ '__nvptx_stacks', '__nvptx_uni' declarations.
+ (nvptx_file_end): Don't emit duplicate declarations for those.
+
* config/nvptx/nvptx.md (nvptx_uniform_warp_check): Make fit for
non-full-warp execution.
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index a36ea48f47c..754eecdaf87 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -180,9 +180,11 @@ static GTY(()) tree global_lock_var;
/* True if any function references __nvptx_stacks. */
static bool need_softstack_decl;
+static bool have_softstack_decl;
/* True if any function references __nvptx_uni. */
static bool need_unisimt_decl;
+static bool have_unisimt_decl;
static int nvptx_mach_max_workers ();
@@ -2571,6 +2573,13 @@ nvptx_assemble_undefined_decl (FILE *file, const char *name, const_tree decl)
TREE_TYPE (decl), size ? tree_to_shwi (size) : 0,
DECL_ALIGN (decl), true);
nvptx_assemble_decl_end ();
+
+ static tree softstack_id = get_identifier ("__nvptx_stacks");
+ static tree unisimt_id = get_identifier ("__nvptx_uni");
+ if (DECL_NAME (decl) == softstack_id)
+ have_softstack_decl = true;
+ else if (DECL_NAME (decl) == unisimt_id)
+ have_unisimt_decl = true;
}
/* Output a pattern for a move instruction. */
@@ -6051,7 +6060,7 @@ nvptx_file_end (void)
write_shared_buffer (asm_out_file, gang_private_shared_sym,
gang_private_shared_align, gang_private_shared_size);
- if (need_softstack_decl)
+ if (need_softstack_decl && !have_softstack_decl)
{
write_var_marker (asm_out_file, false, true, "__nvptx_stacks");
/* 32 is the maximum number of warps in a block. Even though it's an
@@ -6060,7 +6069,8 @@ nvptx_file_end (void)
fprintf (asm_out_file, ".extern .shared .u%d __nvptx_stacks[32];\n",
POINTER_SIZE);
}
- if (need_unisimt_decl)
+
+ if (need_unisimt_decl && !have_unisimt_decl)
{
write_var_marker (asm_out_file, false, true, "__nvptx_uni");
fprintf (asm_out_file, ".extern .shared .u32 __nvptx_uni[32];\n");
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index ea3744044bc..266f719039d 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,5 +1,9 @@
2023-01-20 Thomas Schwinge <thomas@codesourcery.com>
+ * gcc.target/nvptx/softstack-decl-1.c: Make 'dg-do assemble',
+ adjust.
+ * gcc.target/nvptx/uniform-simt-decl-1.c: Likewise.
+
* gcc.target/nvptx/softstack-decl-1.c: New.
* gcc.target/nvptx/uniform-simt-decl-1.c: Likewise.
diff --git a/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c b/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c
index c502eacc1b3..2415f6adb1f 100644
--- a/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/softstack-decl-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do assemble } */
/* { dg-options {-save-temps -O0 -msoft-stack} } */
extern void *__nvptx_stacks[32] __attribute__((shared,nocommon));
@@ -14,7 +14,7 @@ void *f()
return stack_array[5];
}
-/* The implicit (via 'need_softstack_decl') and explicit declarations of
- '__nvptx_stacks' are both emitted:
- { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 2 } }
+/* Of the implicit (via 'need_softstack_decl') and explicit declarations of
+ '__nvptx_stacks', only one is emitted:
+ { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 1 } }
*/
diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c b/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c
index 486456ab243..5a975bdb269 100644
--- a/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-decl-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do assemble } */
/* { dg-options {-save-temps -O0 -muniform-simt} } */
extern unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
@@ -23,7 +23,7 @@ int f (void)
MEMMODEL_RELAXED);
}
-/* The implicit (via 'need_unisimt_decl') and explicit declarations of
- '__nvptx_uni' are both emitted:
- { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 2 } }
+/* Of the implicit (via 'need_unisimt_decl') and explicit declarations of
+ '__nvptx_uni', only one is emitted:
+ { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 1 } }
*/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-19 16:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19 16:51 [gcc/devel/omp/gcc-13] nvptx: Prevent emitting duplicate declarations for '__nvptx_stacks', '__nvptx_uni' Kwok Yeung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).