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

--- Comment #41 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Eric Botcazou from comment #32)
> > It's a bit of a shame I couldn't figure out how to make the zero extend
> > approach work correctly. That aside, I'm concerned that this patch still
> > isn't correct, because it doesn't seem to be using the parallel rtx
> > correctly.
> 
> No worries, it's the standard way of requesting a scratch register, and
> nothing will try to use the result of a CLOBBER on it.  That being said, we
> could indeed try and split the instructions for better scheduling, although
> the TLS pattern for the Sun linker is multi-insn too, see
> tls_initial_exec_64_sun.

No, please don't look there, it is just an old forgotten insn pattern, indented
for an old quirky sun linker (where nobody knows details of its quirks
anymore). It should be converted to split the asm sequence, or (even better)
removed altogether by raising the minimum linker version.

Multi insn can be used as an interim solution, but please use modern approach
to create TLS sequences. All infrastructure is already there.

Looking at Comment #19 testcase:

a) Create _tls_index symbol in a similar way to ix86_tls_get_addr or
ix86_tls_module_base (i386.cc). Using this RTX in your sequence will take care
of (%rip) suffix and different number of _ prefixes automatically

b) Create thread pointer using get_thread_pointer<mode> expander. Please note
how initial RTX is split to use generic moves using memory location with
address space with an absolute offset (const0_rtx in case of ELF).

c) Emit complete TLS sequence in legitimize_tls_address (i386.cc). Please see
TLS_MODEL_INITIAL_EXEC part for your case.

Using the above approach, you won't need any special move instructions because
generic moves should be able to handle all specifics of the TLS sequence. You
will have to add your UNSPEC to various predicate functions, perhaps you should
grep for UNSPEC_GOTTPOFF and add your new unspec nearby.

Reply via email to