On Tue, Apr 29, 2025 at 5:30 PM Uros Bizjak <ubiz...@gmail.com> wrote:
>
> On Tue, Apr 29, 2025 at 9:56 AM H.J. Lu <hjl.to...@gmail.com> wrote:
> >
> > Don't expand UNSPEC_TLS_LD_BASE to a call so that the RTL local copy
> > propagation pass can eliminate multiple __tls_get_addr calls.
>
> __tls_get_addr needs to be called with 16-byte aligned stack, I don't
> think the compiler will correctly handle required call alignment if
> you emit the call without emit_libcall_block.

ix86_split_tls_local_dynamic_base_64 generates the same sequence
as emit_libcall_block.  stack alignment is handled by

(define_expand "@tls_local_dynamic_base_64_<mode>"
  [(set (match_operand:P 0 "register_operand")
    (unspec:P
     [(match_operand 1 "constant_call_address_operand")
      (reg:P SP_REG)]
     UNSPEC_TLS_LD_BASE))]
  "TARGET_64BIT"
  "ix86_tls_descriptor_calls_expanded_in_cfun = true;")

> Uros.
>
> >
> > gcc/
> >
> > PR target/81501
> > * config/i386/i386-protos.h (ix86_split_tls_local_dynamic_base_64):
> > New.
> > * config/i386/i386.cc (ix86_split_tls_local_dynamic_base_64): New.
> > (legitimize_tls_address): Don't emit the 64-bit UNSPEC_TLS_LD_BASE
> > as a call.
> > * config/i386/i386.md (*tls_local_dynamic_base_64_<mode>): Renamed
> > to ...
> > (@tls_local_dynamic_base_call_64_<mode>): This.  Replace
> > (match_operand 2) with (const_int 0).
> > (@tls_local_dynamic_base_64_<mode>): Change call to unspec.
> > (*tls_local_dynamic_base_64_<mode>): New.
> >
> > gcc/testsuite/
> >
> > PR target/81501
> > * gcc.target/i386/pr81501-1.c: New test.
> >
> > OK for master?
> >
> > Thanks.
> >
> > --
> > H.J.



-- 
H.J.

Reply via email to