This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Call tls_get_addr via GOT for GNU TLS if possible


On Fri, Jun 24, 2016 at 5:59 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> There are extensions to x86-64 psABI:
>
> https://groups.google.com/forum/#!topic/x86-64-abi/de5_KnLHxtI
>
> and i386 psABI:
>
> https://groups.google.com/forum/#!topic/ia32-abi/awsRSvJOJfs
>
> to call tls_get_addr via GOT.  X86 assembler and linker in binutils 2.27
> implemented
>
> call *__tls_get_addr@GOTPCREL(%rip)
>
> in 64-bit and
>
> call *___tls_get_addr@GOT(%reg)
>
> in 32-bit to access global and local thread loal variables in shared
> library. We check if 32-bit x86 assembler and linker work with
>
> call *___tls_get_addr@GOT(%reg)
>
> as 32-bit and 64-bit assembler and linker are enabled togther.
>
> In 32-bit, since any integer register except EAX, which is used to pass
> parameter to ___tls_get_addr, and ESP, can be used as GOT base, a new
> register class, TLS_REGS, along with a new constraint, Yb, are added.
> They are used to improve register allocation for 32-bit dynamic TLS
> patterns.
>
> Tested on i686 and x86-64.  OK for trunk?
>
> Thanks.
>
> H.J.
> ---
> gcc/
>
>         * configure.ac (calling ___tls_get_addr via GOT): New
>         assembler/linker check.
>         (HAVE_AS_IX86_TLS_GET_ADDR_GOT): New.  Defined to 1 if 32-bit
>         assembler and linker supports calling ___tls_get_addr via GOT.
>         Otherise, defined to 0.
>         * config.in: Regenerated.
>         * configure: Likewise.
>         * config/i386/constraints.md (Yb): New constraint.
>         * config/i386/i386.h (reg_class): Add TLS_REGS.
>         (REG_CLASS_NAMES): Add TLS_REGS.
>         (REG_CLASS_CONTENTS): Likewise.
>         * config/i386/i386.md (*tls_global_dynamic_32_gnu): Replace
>         the b constraint with the Yb constraint.  Call ___tls_get_addr
>         via GOT for GNU TLS with -fno-plt if HAVE_AS_IX86_TLS_GET_ADDR_GOT
>         is 1.
>         (*tls_local_dynamic_base_32_gnu): Likewise.
>         (*tls_global_dynamic_64_<mode>): Call _tls_get_addr via GOT for
>         GNU TLS with -fno-plt if HAVE_AS_IX86_TLS_GET_ADDR_GOT is 1.
>         (*tls_local_dynamic_base_64_<mode>): Likewise.
>
> gcc/testsuite/
>
>         * gcc.target/i386/noplt-gd-1.c: New test.
>         * gcc.target/i386/noplt-gd-2.c: Likewise.
>         * gcc.target/i386/noplt-gd-3.c: Likewise.
>         * gcc.target/i386/noplt-ld-1.c: Likewise.
>         * gcc.target/i386/noplt-ld-2.c: Likewise.
>         * gcc.target/i386/noplt-ld-3.c: Likewise.
>         * lib/target-supports.exp
>         (check_effective_target_tls_get_addr_via_got): New.

OK for mainline, but please name new register class TLS_GOTBASE_REGS.

Thanks,
Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]