]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/78796 (TLS fails to link on aarch64 with -mcmodel=large)
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:48:57 +0000 (09:48 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:48:57 +0000 (09:48 +0200)
Backported from mainline
2016-12-14  Wilco Dijkstra  <wdijkstr@arm.com>
    Jakub Jelinek  <jakub@redhat.com>

PR target/78796
* config/aarch64/aarch64.c (aarch64_classify_symbol): Merge large
model checks into switch.

* gcc.dg/tls/pr78796.c: New test.

From-SVN: r248632

gcc/ChangeLog
gcc/config/aarch64/aarch64.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tls/pr78796.c [new file with mode: 0644]

index 43786fa65e23847a07ba0afc40e099635dd4a420..1a43a0e96d22103f724767f790fb51a88570b7fc 100644 (file)
@@ -1,6 +1,13 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-12-14  Wilco Dijkstra  <wdijkstr@arm.com>
+                   Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/78796
+       * config/aarch64/aarch64.c (aarch64_classify_symbol): Merge large
+       model checks into switch.
+
        2016-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/78298
index 4113609d470ff21de47a647217fd20be4c967225..a918e679c2e312d281a0be98ec11bacef9eb034b 100644 (file)
@@ -7069,9 +7069,6 @@ aarch64_classify_symbol (rtx x, rtx offset,
 
   if (GET_CODE (x) == SYMBOL_REF)
     {
-      if (aarch64_cmodel == AARCH64_CMODEL_LARGE)
-         return SYMBOL_FORCE_TO_MEM;
-
       if (aarch64_tls_symbol_p (x))
        return aarch64_classify_tls_symbol (x);
 
@@ -7110,6 +7107,9 @@ aarch64_classify_symbol (rtx x, rtx offset,
            return SYMBOL_SMALL_GOT;
          return SYMBOL_SMALL_ABSOLUTE;
 
+       case AARCH64_CMODEL_LARGE:
+         return SYMBOL_FORCE_TO_MEM;
+
        default:
          gcc_unreachable ();
        }
index 303b4ab4025497a9df1bf092e2aab5b4d1c1a1d4..4734c07d052a6a8197ff776cc05880289b3f8365 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-12-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/78796
+       * gcc.dg/tls/pr78796.c: New test.
+
        2016-12-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/78649
diff --git a/gcc/testsuite/gcc.dg/tls/pr78796.c b/gcc/testsuite/gcc.dg/tls/pr78796.c
new file mode 100644 (file)
index 0000000..12263da
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR target/78796 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-mcmodel=large" { target aarch64-*-* } } */
+/* { dg-require-effective-target tls } */
+
+struct S { int a, b, c, d, e; };
+struct S t;
+__thread struct S s;
+
+__attribute__((used, noinline, noclone)) void
+foo (int *x, int *y)
+{
+  asm volatile ("" : : "g" (x), "g" (y) : "memory");
+  if (*x != 1 || *y != 2)
+    __builtin_abort ();
+}
+
+__attribute__((used, noinline, noclone)) void
+bar (void)
+{
+  foo (&t.c, &s.c);
+}
+
+int
+main ()
+{
+  t.c = 1;
+  s.c = 2;
+  bar ();
+  return 0;
+}