This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix TLS related ICE on IA-32
- From: Jakub Jelinek <jakub at redhat dot com>
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org, drepper at redhat dot com, roland at redhat dot com
- Date: Wed, 11 Sep 2002 00:10:02 +0200
- Subject: [PATCH] Fix TLS related ICE on IA-32
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The run-2.c testcase below ICEs on IA-32 with unrecognizable insn:
(insn 17 33 19 (set (reg/f:SI 61)
(const:SI (plus:SI (unspec:SI[
(symbol_ref/v:SI ("%Lx"))
] 23)
(const_int 8 [0x8])))) -1 (nil)
(expr_list:REG_EQUAL (const:SI (plus:SI (unspec:SI[
(symbol_ref/v:SI ("%Lx"))
] 23)
(const_int 8 [0x8])))
(nil)))
As withouth -fpic gcc already uses 8+x@NTPOFF(%eax) etc., I think we
should just allow offsetting NTPOFF and DTPOFF.
It needs a binutils fix I've posted today though.
The run-1.c testcase shows the binutils bug.
I'm not sure if we want dg-do run TLS tests in the testsuite yet, as
it requires TLS enabled glibc. If not, I'll just change the run-2.c
test to dg-do compile one.
2002-09-10 Jakub Jelinek <jakub@redhat.com>
* config/i386/i386.c (legitimate_pic_address_disp_p): Allow
UNSPEC_NTPOFF and UNSPEC_DTPOFF to be offsetted by constant.
* gcc.dg/tls/run-1.c: New test.
* gcc.dg/tls/run-2.c: New test.
--- gcc/config/i386/i386.c.jj 2002-09-10 13:47:39.000000000 +0200
+++ gcc/config/i386/i386.c 2002-09-10 14:40:49.000000000 +0200
@@ -5041,14 +5041,8 @@ legitimate_pic_address_disp_p (disp)
return false;
return initial_exec_symbolic_operand (XVECEXP (disp, 0, 0), Pmode);
case UNSPEC_NTPOFF:
- /* ??? Could support offset here. */
- if (saw_plus)
- return false;
return local_exec_symbolic_operand (XVECEXP (disp, 0, 0), Pmode);
case UNSPEC_DTPOFF:
- /* ??? Could support offset here. */
- if (saw_plus)
- return false;
return local_dynamic_symbolic_operand (XVECEXP (disp, 0, 0), Pmode);
}
--- gcc/testsuite/gcc.dg/tls/run-1.c.jj 2002-09-10 14:16:38.000000000 +0200
+++ gcc/testsuite/gcc.dg/tls/run-1.c 2002-09-10 14:14:31.000000000 +0200
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftls-model=local-exec" } */
+
+struct S {
+ int s0, s1, s2, s3;
+};
+static __thread struct S x;
+extern void abort (void);
+extern void exit (int);
+
+void
+foo (struct S *s)
+{
+ s->s2 = 231;
+}
+
+void
+bar (void)
+{
+ if (x.s0 == 231 || x.s2 != 231)
+ abort ();
+}
+
+int
+main ()
+{
+ foo (&x);
+ bar ();
+ exit (0);
+}
--- gcc/testsuite/gcc.dg/tls/run-2.c.jj 2002-09-10 14:16:38.000000000 +0200
+++ gcc/testsuite/gcc.dg/tls/run-2.c 2002-09-10 14:21:33.000000000 +0200
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fpic -ftls-model=local-dynamic" } */
+
+struct S {
+ int s0, s1, s2, s3;
+};
+static __thread struct S x;
+extern void abort (void);
+extern void exit (int);
+
+void
+foo (struct S *s)
+{
+ s->s2 = 231;
+}
+
+void
+bar (void)
+{
+ if (x.s0 == 231 || x.s2 != 231)
+ abort ();
+}
+
+int
+main ()
+{
+ foo (&x);
+ bar ();
+ exit (0);
+}
Jakub