aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2015-11-19 22:05:03 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-11-19 22:05:03 +0000
commit0766660bf94087754e89959cb4b1f27660f30afe (patch)
tree9b58207fedab59f51a80435e8b38056177fd0b25
parent433068ccab80943a0b1dac0fff62d0cfc5c50acb (diff)
downloadgcc-0766660bf94087754e89959cb4b1f27660f30afe.zip
gcc-0766660bf94087754e89959cb4b1f27660f30afe.tar.gz
gcc-0766660bf94087754e89959cb4b1f27660f30afe.tar.bz2
nvptx.h (SUPPORTS_WEAK): Define.
gcc/ * config/nvptx/nvptx.h (SUPPORTS_WEAK): Define. * config/nvptx/nvptx.c (nvptx_write_function_decl): Support DECL_WEAK. (nvptx_declare_objec_name): Likewise. gcc/testsuite/ * lib/target-supports.exp (check_weak_available): Add nvptx-*-*. * gcc.dg/attr-weakref-1.c: Skip for nvptx-*-* * gcc.dg/special/weak-2.c: Likewise. * gcc.dg/weak/weak-12.c: Likewise. * gcc.dg/weak/weak-15.c: Likewise. * gcc.dg/weak/weak-16.c: Likewise. * gcc.dg/weak/weak-1.c: Likewise. * gcc.dg/weak/weak-2.c: Likewise. * gcc.dg/weak/weak-4.c: Likewise. * gcc.dg/torture/pr53922.c: Likewise. * gcc.dg/torture/pr60092.c: Likewise. From-SVN: r230628
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/nvptx/nvptx.c7
-rw-r--r--gcc/config/nvptx/nvptx.h1
-rw-r--r--gcc/testsuite/ChangeLog14
-rw-r--r--gcc/testsuite/gcc.dg/attr-weakref-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr53922.c1
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr60092.c1
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-12.c2
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-15.c2
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-16.c2
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/weak/weak-4.c2
-rw-r--r--gcc/testsuite/lib/target-supports.exp6
15 files changed, 54 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cf75f44..5fd82d2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-11-19 Nathan Sidwell <nathan@acm.org>
+
+ * config/nvptx/nvptx.h (SUPPORTS_WEAK): Define.
+ * config/nvptx/nvptx.c (nvptx_write_function_decl): Support
+ DECL_WEAK.
+ (nvptx_declare_objec_name): Likewise.
+
2015-11-19 Aditya Kumar <aditya.k7@samsung.com>
* graphite-isl-ast-to-gimple.c (get_true_edge_from_guard_bb): Move...
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 62c6faa..044f545 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -379,7 +379,7 @@ nvptx_write_function_decl (std::stringstream &s, const char *name, const_tree de
if (DECL_EXTERNAL (decl))
s << ".extern ";
else if (TREE_PUBLIC (decl))
- s << ".visible ";
+ s << (DECL_WEAK (decl) ? ".weak " : ".visible ");
if (kernel)
s << ".entry ";
@@ -1780,8 +1780,9 @@ nvptx_declare_object_name (FILE *file, const char *name, const_tree decl)
size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
const char *section = nvptx_section_for_decl (decl);
fprintf (file, "\t%s%s .align %d .u%d ",
- TREE_PUBLIC (decl) ? " .visible" : "", section,
- DECL_ALIGN (decl) / BITS_PER_UNIT,
+ !TREE_PUBLIC (decl) ? ""
+ : DECL_WEAK (decl) ? ".weak" : ".visible",
+ section, DECL_ALIGN (decl) / BITS_PER_UNIT,
decl_chunk_size * BITS_PER_UNIT);
assemble_name (file, name);
if (size > 0)
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 018b844..1a497be 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -349,6 +349,7 @@ struct GTY(()) machine_function
#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
+#define SUPPORTS_WEAK 1
#define NO_DOT_IN_LABEL
#define ASM_COMMENT_START "//"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 16a6167..ebfe4f9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,17 @@
+2015-11-19 Nathan Sidwell <nathan@acm.org>
+
+ * lib/target-supports.exp (check_weak_available): Add nvptx-*-*.
+ * gcc.dg/attr-weakref-1.c: Skip for nvptx-*-*
+ * gcc.dg/special/weak-2.c: Likewise.
+ * gcc.dg/weak/weak-12.c: Likewise.
+ * gcc.dg/weak/weak-15.c: Likewise.
+ * gcc.dg/weak/weak-16.c: Likewise.
+ * gcc.dg/weak/weak-1.c: Likewise.
+ * gcc.dg/weak/weak-2.c: Likewise.
+ * gcc.dg/weak/weak-4.c: Likewise.
+ * gcc.dg/torture/pr53922.c: Likewise.
+ * gcc.dg/torture/pr60092.c: Likewise.
+
2015-11-19 Marek Polacek <polacek@redhat.com>
PR c/68412
diff --git a/gcc/testsuite/gcc.dg/attr-weakref-1.c b/gcc/testsuite/gcc.dg/attr-weakref-1.c
index 9ed1c51..d327b40 100644
--- a/gcc/testsuite/gcc.dg/attr-weakref-1.c
+++ b/gcc/testsuite/gcc.dg/attr-weakref-1.c
@@ -1,10 +1,12 @@
// { dg-do run }
// { dg-require-weak "" }
// On darwin, we use attr-weakref-1-darwin.c.
+
// This test requires support for undefined weak symbols. This support
-// is not available on hppa*-*-hpux*. The test is skipped rather than
+// is not available on the following targets. The test is skipped rather than
// xfailed to suppress the warning that would otherwise arise.
-// { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" } "*" { "" } }
+// { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "nvptx-*-*" } "*" { "" } }
+
// For kernel modules and static RTPs, the loader treats undefined weak
// symbols in the same way as undefined strong symbols. The test
// therefore fails to load, so skip it.
diff --git a/gcc/testsuite/gcc.dg/special/weak-2.c b/gcc/testsuite/gcc.dg/special/weak-2.c
index b93a8ef..91a92e6 100644
--- a/gcc/testsuite/gcc.dg/special/weak-2.c
+++ b/gcc/testsuite/gcc.dg/special/weak-2.c
@@ -2,6 +2,10 @@
/* { dg-require-weak "" } */
/* { dg-additional-sources "weak-2a.c weak-2b.c" } */
+/* NVPTX's implementation of weak is broken when a strong symbol is in
+ a later object file than the weak definition. */
+/* { dg-skip-if "" { "nvptx-*-*" } "*" { "" } } */
+
#include <stdlib.h>
extern int foo(void);
diff --git a/gcc/testsuite/gcc.dg/torture/pr53922.c b/gcc/testsuite/gcc.dg/torture/pr53922.c
index 3974dc6..fac054d 100644
--- a/gcc/testsuite/gcc.dg/torture/pr53922.c
+++ b/gcc/testsuite/gcc.dg/torture/pr53922.c
@@ -3,6 +3,7 @@
/* { dg-skip-if "No undefined" { *-*-mingw* } { "*" } { "" } } */
/* { dg-skip-if "No undefined weak" { *-*-aix* } { "*" } { "" } } */
/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } { "*" } { "" } } */
+/* { dg-skip-if "No undefined weak" { nvptx-*-* } { "*" } { "" } } */
/* { dg-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr60092.c b/gcc/testsuite/gcc.dg/torture/pr60092.c
index 337ff52..d66e3f2 100644
--- a/gcc/testsuite/gcc.dg/torture/pr60092.c
+++ b/gcc/testsuite/gcc.dg/torture/pr60092.c
@@ -1,6 +1,7 @@
/* { dg-do run } */
/* { dg-require-weak "" } */
/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */
+/* { dg-skip-if "No undefined weak" { nvptx-*-* } { "*" } { "" } } */
/* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
/* { dg-xfail-run-if "posix_memalign modifies first arg on error" { *-*-solaris2.11* } { "-O0" } } */
diff --git a/gcc/testsuite/gcc.dg/weak/weak-1.c b/gcc/testsuite/gcc.dg/weak/weak-1.c
index 14e9de7..dc34079 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-1.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-1.c
@@ -2,6 +2,8 @@
/* { dg-require-weak "" } */
/* { dg-options "-fno-common" } */
/* { dg-skip-if "" { *-*-mingw* } { "*" } { "" } } */
+/* NVPTX's definition of weak looks different to normal. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?a" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?b" } } */
diff --git a/gcc/testsuite/gcc.dg/weak/weak-12.c b/gcc/testsuite/gcc.dg/weak/weak-12.c
index 72cc144..72f8991 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-12.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-12.c
@@ -2,6 +2,8 @@
/* { dg-do compile } */
/* { dg-require-weak "" } */
/* { dg-options "" } */
+/* NVPTX's weak is applied to the definition, not declaration. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?foo" } } */
diff --git a/gcc/testsuite/gcc.dg/weak/weak-15.c b/gcc/testsuite/gcc.dg/weak/weak-15.c
index 34b089b..d656d21 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-15.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-15.c
@@ -2,6 +2,8 @@
/* { dg-require-weak "" } */
/* { dg-options "-fno-common" } */
/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
+/* NVPTX's weak is applied to the definition, not declaration. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?a" } } */
/* { dg-final { scan-assembler-not "weak\[^ \t\]*\[ \t\]_?b" } } */
diff --git a/gcc/testsuite/gcc.dg/weak/weak-16.c b/gcc/testsuite/gcc.dg/weak/weak-16.c
index d557a6e..b1a08ea 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-16.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-16.c
@@ -5,6 +5,8 @@
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?kallsyms_token_index" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?kallsyms_token_table" } } */
/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
+/* NVPTX's weak is applied to the definition, not declaration. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
extern int kallsyms_token_index[] __attribute__((weak));
extern int kallsyms_token_table[] __attribute__((weak));
diff --git a/gcc/testsuite/gcc.dg/weak/weak-2.c b/gcc/testsuite/gcc.dg/weak/weak-2.c
index b328c3c..cad6e7b1 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-2.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-2.c
@@ -2,6 +2,8 @@
/* { dg-require-weak "" } */
/* { dg-options "-fno-common" } */
/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
+/* NVPTX's definition of weak looks different to normal. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?ffoo1a" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?ffoo1b" } } */
diff --git a/gcc/testsuite/gcc.dg/weak/weak-4.c b/gcc/testsuite/gcc.dg/weak/weak-4.c
index a84f580..d2d0e68 100644
--- a/gcc/testsuite/gcc.dg/weak/weak-4.c
+++ b/gcc/testsuite/gcc.dg/weak/weak-4.c
@@ -2,6 +2,8 @@
/* { dg-require-weak "" } */
/* { dg-options "-fno-common" } */
/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
+/* NVPTX's definition of weak looks different to normal. */
+/* { dg-skip-if "" { nvptx-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1a" } } */
/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1b" } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 4f2d815..66fc100 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -292,6 +292,12 @@ proc check_weak_available { } {
return 0
}
+ # nvptx (nearly) supports it
+
+ if { [istarget nvptx-*-*] } {
+ return 1
+ }
+
# ELF and ECOFF support it. a.out does with gas/gld but may also with
# other linkers, so we should try it