OSDN Git Service

PR target/29198
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Oct 2006 07:25:02 +0000 (07:25 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 Oct 2006 07:25:02 +0000 (07:25 +0000)
* config/i386/i386.c (legitimize_pic_address): Reject TLS symbols.
* config/i386/predicates.md (local_symbolic_operand): Likewise.

* gcc.dg/tls/opt-12.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117483 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tls/opt-12.c [new file with mode: 0644]

index 3eaecfe..59bafde 100644 (file)
@@ -1,5 +1,9 @@
 2006-10-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/29198
+       * config/i386/i386.c (legitimize_pic_address): Reject TLS symbols.
+       * config/i386/predicates.md (local_symbolic_operand): Likewise.
+
        PR c/29091
        * varasm.c (output_constant): If TREE_VECTOR_CST_ELTS chain is shorter than
        the number of vector elements fill the rest with zeros.
index cdbd0c6..287163e 100644 (file)
@@ -6623,7 +6623,7 @@ legitimize_pic_address (rtx orig, rtx reg)
          new = reg;
        }
     }
-  else if (GET_CODE (addr) == SYMBOL_REF)
+  else if (GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (addr) == 0)
     {
       if (TARGET_64BIT)
        {
index 457f556..5201191 100644 (file)
   if (GET_CODE (op) != SYMBOL_REF)
     return 0;
 
+  if (SYMBOL_REF_TLS_MODEL (op) != 0)
+    return 0;
+
   if (SYMBOL_REF_LOCAL_P (op))
     return 1;
 
index ce15a0f..5027cb4 100644 (file)
@@ -1,5 +1,8 @@
 2006-10-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/29198
+       * gcc.dg/tls/opt-12.c: New test.
+
        PR fortran/28415
        * gfortran.dg/save_2.f90: New test.
 
diff --git a/gcc/testsuite/gcc.dg/tls/opt-12.c b/gcc/testsuite/gcc.dg/tls/opt-12.c
new file mode 100644 (file)
index 0000000..7c6e734
--- /dev/null
@@ -0,0 +1,50 @@
+/* PR target/29198 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fpic" } */
+/* { dg-require-effective-target tls_runtime } */
+/* { dg-require-effective-target fpic } */
+
+extern void abort (void);
+
+int f2 (int, int, int, int);
+struct s { char b[4]; };
+__thread struct s thra[2];
+
+void
+__attribute__((noinline))
+f1 (int a1, int a2)
+{
+  int i, j;
+  for (i = 0; i < 4; i++)
+    {
+      int tot = 0;
+      for (j = 0; j < 4; j++)
+       tot += f2 (a1, a2, i, j);
+      *(&thra[0].b[0] + i) = tot;
+    }
+}
+
+int
+__attribute__((noinline))
+f2 (int a, int b, int c, int d)
+{
+  return a + b + c + d;
+}
+
+int
+main (void)
+{
+  f1 (0, 0);
+  if (thra[0].b[0] != 6
+      || thra[0].b[1] != 10
+      || thra[0].b[2] != 14
+      || thra[0].b[3] != 18)
+    abort ();
+  f1 (2, 3);
+  if (thra[0].b[0] != 26
+      || thra[0].b[1] != 30
+      || thra[0].b[2] != 34
+      || thra[0].b[3] != 38)
+    abort ();
+  return 0;
+}