* [PTX] weak references
@ 2016-06-01 13:44 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2016-06-01 13:44 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
This patch emits an error if you try and weakly reference a declaration. PTX
doesn't support that.
I tried overriding ASM_OUTPUT_WEAREF, but that didn't seem to work. So this is
added to the assemble_undefined_decl hook. that does mean it requires
-ftoplevel-reorder to function, but that flags's on for PTX unless explicitly
disabled.
Committed to trunk
nathan
[-- Attachment #2: ptx-weak-decl.patch --]
[-- Type: text/x-patch, Size: 1679 bytes --]
2016-06-01 Nathan Sidwell <nathan@acm.org>
* config/nvptx/nvptx.c (nvptx_assemble_undefined_decl): Reject
undefined weak.
testsuite/
* c-c++-common/torture/pr57945.c: Add expected PTX error.
* gcc.target/nvptx/weak.c: New.
Index: config/nvptx/nvptx.c
===================================================================
--- config/nvptx/nvptx.c (revision 236919)
+++ config/nvptx/nvptx.c (working copy)
@@ -1777,6 +1777,12 @@ nvptx_assemble_undefined_decl (FILE *fil
if (DECL_IN_CONSTANT_POOL (decl))
return;
+ /* We support weak defintions, and hence have the right
+ ASM_WEAKEN_DECL definition. Diagnose the problem here. */
+ if (DECL_WEAK (decl))
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "PTX does not support weak declarations"
+ " (only weak definitions)");
write_var_marker (file, false, TREE_PUBLIC (decl), name);
fprintf (file, "\t.extern ");
Index: testsuite/c-c++-common/torture/pr57945.c
===================================================================
--- testsuite/c-c++-common/torture/pr57945.c (revision 236919)
+++ testsuite/c-c++-common/torture/pr57945.c (working copy)
@@ -9,3 +9,5 @@ foo (void)
{
return &i ? i : 0;
}
+
+/* { dg-error "PTX does not support weak declarations" "" { target nvptx-*-* } 5 } */
Index: testsuite/gcc.target/nvptx/weak.c
===================================================================
--- testsuite/gcc.target/nvptx/weak.c (nonexistent)
+++ testsuite/gcc.target/nvptx/weak.c (working copy)
@@ -0,0 +1,9 @@
+
+extern int __attribute__((weak)) decl; /* { dg-error "weak declarations" } */
+int __attribute__((weak)) defn;
+
+int Foo ()
+{
+ return decl + defn;
+}
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-01 13:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 13:44 [PTX] weak references Nathan Sidwell
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).