From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PTX] weak references
Date: Wed, 01 Jun 2016 13:44:00 -0000 [thread overview]
Message-ID: <b3571f8e-36da-5448-7bfa-8073af132fa4@acm.org> (raw)
[-- 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;
+}
+
reply other threads:[~2016-06-01 13:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3571f8e-36da-5448-7bfa-8073af132fa4@acm.org \
--to=nathan@acm.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).