On Tue, Mar 13, 2012 at 8:11 AM, Uros Bizjak <ubiz...@gmail.com> wrote:
>>>> 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 <ubiz...@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. OTOH, we can improve rejection test a bit to reject only non-word mode registers. 2012-03-13 Uros Bizjak <ubiz...@gmail.com> * config/i386/i386.c (ix86_decompose_address): Prevent %fs:(%reg) addresses only when %reg is not in word mode. Tested on x86_64-pc-linux-gnu {,-m32}, committed. Uros. Index: i386.c =================================================================== --- i386.c (revision 185278) +++ i386.c (working copy) @@ -11563,8 +11563,10 @@ return 0; } - if (seg != SEG_DEFAULT && (base || index) - && !TARGET_TLS_INDIRECT_SEG_REFS) +/* Address override works only on the (%reg) part of %fs:(%reg). */ + if (seg != SEG_DEFAULT + && ((base && GET_MODE (base) != word_mode) + || (index && GET_MODE (index) != word_mode))) return 0; /* Extract the integral value of scale. */