* [PATCH] Fix TLS ICE with -mcmodel=large (PR target/89290)
@ 2019-02-12 23:01 Jakub Jelinek
2019-02-13 8:26 ` Uros Bizjak
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-02-12 23:01 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
Hi!
The following patch fixes ICE, when we try to split a double-word TLS load
or store. The problem is that x86_64_immediate_operand disallows CONST_INT
offsets with -mcmodel=large. I guess it is intentional for SYMBOL_REFs,
LABEL_REFs etc., but for the TLS LE UNSPECs it should be fine, there are no
64-bit relocations for these, we don't really support > 2GB thread local
segments.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2019-02-12 Jakub Jelinek <jakub@redhat.com>
PR target/89290
* config/i386/predicates.md (x86_64_immediate_operand): Allow
TLS UNSPECs offsetted by signed 32-bit CONST_INT even with
-mcmodel=large.
* gcc.target/i386/pr89290.c: New test.
--- gcc/config/i386/predicates.md.jj 2019-01-01 12:37:32.267727037 +0100
+++ gcc/config/i386/predicates.md 2019-02-12 17:07:15.937097266 +0100
@@ -182,7 +182,7 @@ (define_predicate "x86_64_immediate_oper
rtx op1 = XEXP (XEXP (op, 0), 0);
rtx op2 = XEXP (XEXP (op, 0), 1);
- if (ix86_cmodel == CM_LARGE)
+ if (ix86_cmodel == CM_LARGE && GET_CODE (op1) != UNSPEC)
return false;
if (!CONST_INT_P (op2))
return false;
--- gcc/testsuite/gcc.target/i386/pr89290.c.jj 2019-02-12 17:32:49.291750588 +0100
+++ gcc/testsuite/gcc.target/i386/pr89290.c 2019-02-12 17:34:00.847568163 +0100
@@ -0,0 +1,19 @@
+/* PR target/89290 */
+/* { dg-do compile { target { tls && lp64 } } } */
+/* { dg-options "-O0 -mcmodel=large" } */
+
+struct S { long int a, b; } e;
+__thread struct S s;
+__thread struct S t[2];
+
+void
+foo (void)
+{
+ s = e;
+}
+
+void
+bar (void)
+{
+ t[1] = e;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix TLS ICE with -mcmodel=large (PR target/89290)
2019-02-12 23:01 [PATCH] Fix TLS ICE with -mcmodel=large (PR target/89290) Jakub Jelinek
@ 2019-02-13 8:26 ` Uros Bizjak
0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2019-02-13 8:26 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Wed, Feb 13, 2019 at 12:01 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> The following patch fixes ICE, when we try to split a double-word TLS load
> or store. The problem is that x86_64_immediate_operand disallows CONST_INT
> offsets with -mcmodel=large. I guess it is intentional for SYMBOL_REFs,
> LABEL_REFs etc., but for the TLS LE UNSPECs it should be fine, there are no
> 64-bit relocations for these, we don't really support > 2GB thread local
> segments.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2019-02-12 Jakub Jelinek <jakub@redhat.com>
>
> PR target/89290
> * config/i386/predicates.md (x86_64_immediate_operand): Allow
> TLS UNSPECs offsetted by signed 32-bit CONST_INT even with
> -mcmodel=large.
>
> * gcc.target/i386/pr89290.c: New test.
OK.
Thanks,
Uros.
> --- gcc/config/i386/predicates.md.jj 2019-01-01 12:37:32.267727037 +0100
> +++ gcc/config/i386/predicates.md 2019-02-12 17:07:15.937097266 +0100
> @@ -182,7 +182,7 @@ (define_predicate "x86_64_immediate_oper
> rtx op1 = XEXP (XEXP (op, 0), 0);
> rtx op2 = XEXP (XEXP (op, 0), 1);
>
> - if (ix86_cmodel == CM_LARGE)
> + if (ix86_cmodel == CM_LARGE && GET_CODE (op1) != UNSPEC)
> return false;
> if (!CONST_INT_P (op2))
> return false;
> --- gcc/testsuite/gcc.target/i386/pr89290.c.jj 2019-02-12 17:32:49.291750588 +0100
> +++ gcc/testsuite/gcc.target/i386/pr89290.c 2019-02-12 17:34:00.847568163 +0100
> @@ -0,0 +1,19 @@
> +/* PR target/89290 */
> +/* { dg-do compile { target { tls && lp64 } } } */
> +/* { dg-options "-O0 -mcmodel=large" } */
> +
> +struct S { long int a, b; } e;
> +__thread struct S s;
> +__thread struct S t[2];
> +
> +void
> +foo (void)
> +{
> + s = e;
> +}
> +
> +void
> +bar (void)
> +{
> + t[1] = e;
> +}
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-13 8:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 23:01 [PATCH] Fix TLS ICE with -mcmodel=large (PR target/89290) Jakub Jelinek
2019-02-13 8:26 ` Uros Bizjak
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).