https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80881

--- Comment #48 from Uroš Bizjak <ubizjak at gmail dot com> ---
Comment on attachment 59315
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59315
Candidate patch

>+static rtx
>+ix86_tls_index (void)
>+{
>+  if (!ix86_tls_index_symbol)
>+    ix86_tls_index_symbol = gen_rtx_SYMBOL_REF (Pmode, "_tls_index");
>+
>+  if (flag_pic)
>+    {
>+      rtx unspec = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, 
>ix86_tls_index_symbol),
>+                                 UNSPEC_PCREL);
>+      return gen_rtx_CONST (Pmode, unspec);

Please note that RIP-relative addresses are one byte shorter than absolute
addresses and are interchangeable on x86_64 Linux. If this is also true on
Windows (UNSPEC_PCREL was introduced for PE linkers) then the above should also
be emitted without flag_pic. Looking through the i386.cc, there are some
(flag_pic) asserts w/ UNSPEC_PCREL), but perhaps these can be relaxed to also
support RIP-relative addresses without -fPIC.

Reply via email to