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: Properly generate X32 IE sequence


On Tue, Mar 13, 2012 at 2:20 AM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>>> Here is the patch which is equivalent to clearing MASK_TLS_DIRECT_SEG_REFS
>>>> when Pmode != word_mode. ?We need to keep
>>>>
>>>> ? ? ? ? ?else if (Pmode == SImode)
>>>> ? ? ? ? ? ?{
>>>> ? ? ? ? ? ? ?/* Always generate
>>>> ? ? ? ? ? ? ? ? ? ? ? ?movl %fs:0, %reg32
>>>> ? ? ? ? ? ? ? ? ? ? ? ?addl xgottpoff(%rip), %reg32
>>>> ? ? ? ? ? ? ? ? to support linker IE->LE optimization and avoid
>>>> ? ? ? ? ? ? ? ? fs:(%reg32) as memory operand. ?*/
>>>> ? ? ? ? ? ? ?dest = gen_reg_rtx (Pmode);
>>>> ? ? ? ? ? ? ?emit_insn (gen_tls_initial_exec_x32 (dest, x));
>>>> ? ? ? ? ? ? ?return dest;
>>>> ? ? ? ? ? ?}
>>>>
>>>> to support linker IE->LE optimization. ?TARGET_TLS_DIRECT_SEG_REFS only affects
>>>> TLS LE access and fs:(%reg) is only generated by combine.
>>>>
>>>> So the main impact of disabling TARGET_TLS_DIRECT_SEG_REFS is to disable
>>>> fs:immediate memory operand for TLS LE access, which doesn't have any problems
>>>> to begin with.
>>>>
>>>> I would prefer to keep TARGET_TLS_DIRECT_SEG_REFS and disable only
>>>> fs:(%reg), which is generated by combine.
>>>
>>> Please try attached patch. ?It introduces TARGET_TLS_INDIRECT_SEG_REFS
>>> to block only indirect seg references.
>
> There is no regression.

Thanks, committed to mainline SVN with following ChangeLog:

2012-03-13  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
	* config/i386/i386.c (ix86_decompose_address): Use
	TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
	(legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
	thread pointer to a register.

Tested on x86_64-pc-linux-gnu {,-m32}.

> BTW, this x32 TLS IE optimization:

 >    movq    %rax, %fs:(%rdx)

This is just looking for troubles. If we said these addresses are
invalid, then we shouldn't generate them.

Uros.


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