On Mon, Jul 25, 2011 at 11:05 PM, H.J. Lu <hjl.to...@gmail.com> wrote:

>>>> Attached patch implements -fpic handling for x32. In x32 mode, we now
>>>> use x86_64_general_operand and corresponding "e" constraints for adds
>>>> in SImode, since it looks that invalid addresses can only be generated
>>>> through adds. This avoids a whole bunch of new predicates and
>>>> constraints.
>>
>>> X32 glibc is miscompiled:
>>>
>>> CPP='/export/build/gnu/gcc-x32/release/usr/gcc-4.7.0-x32/bin/gcc -mx32
>>>  -E -x c-header'
>>> /export/build/gnu/glibc-x32/build-x86_64-linux/elf/ld-linux-x32.so.2
>>> --library-path 
>>> /export/build/gnu/glibc-x32/build-x86_64-linux:/export/build/gnu/glibc-x32/build-x86_64-linux/math:/export/build/gnu/glibc-x32/build-x86_64-linux/elf:/export/build/gnu/glibc-x32/build-x86_64-linux/dlfcn:/export/build/gnu/glibc-x32/build-x86_64-linux/nss:/export/build/gnu/glibc-x32/build-x86_64-linux/nis:/export/build/gnu/glibc-x32/build-x86_64-linux/rt:/export/build/gnu/glibc-x32/build-x86_64-linux/resolv:/export/build/gnu/glibc-x32/build-x86_64-linux/crypt:/export/build/gnu/glibc-x32/build-x86_64-linux/nptl
>>> /export/build/gnu/glibc-x32/build-x86_64-linux/sunrpc/rpcgen -Y
>>> ../scripts -h rpcsvc/yppasswd.x -o
>>> /export/build/gnu/glibc-x32/build-x86_64-linux/sunrpc/rpcsvc/yppasswd.T
>>> make[5]: *** 
>>> [/export/build/gnu/glibc-x32/build-x86_64-linux/sunrpc/rpcsvc/yppasswd.stmp]
>>> Segmentation fault (core dumped)
>>>
>>> Some LEA patterns are wrong for x32.  I will investigate.
>>
>> We have to prevent symbols from entering general_operand predicated
>> SImode operands. Fortunatelly, x86_64_general_operand works OK for
>> x32, while both for i686 and x86_64 are unaffected due to early bypass
>> (i686) and due to the fact that all symbols are DImode (x86_64).
>>
>> 2011-07-25  Uros Bizjak  <ubiz...@gmail.com>
>>            H.J. Lu  <hongjiu...@intel.com>
>>
>>        PR target/47381
>>        PR target/49832
>>        PR target/49833
>>        * config/i386/i386.md (i): Change SImode attribute to "e".
>>        (g): Change SImode attribute to "rme".
>>        (di): Change SImode attribute to "nF".
>>        (general_operand): Change SImode attribute to x86_64_general_operand.
>>        (general_szext_operand): Change SImode attribute to
>>        x86_64_szext_general_operand.
>>        (immediate_operand): Change SImode attribute to
>>        x86_64_immediate_operand-
>>        (*movdi_internal_rex64): Remove mode from pic_32bit_operand check.
>>        (*movsi_internal): Ditto.  Use "e" constraint in alternative 2.
>>        (*lea_1): Use SWI48 mode iterator.
>>        (*lea_1_zext): New insn pattern.
>>        (*add<mode>1): Use x86_64_general_operand predicate for operand 2.
>>        Update operand constraints.
>>        (addsi_1_zext): Ditto.
>>        (*add<mode>2): Ditto.
>>        (*addsi_3_zext): Ditto.
>>        (*subsi_1_zext): Ditto.
>>        (*subsi_2_zext): Ditto.
>>        (*subsi_3_zext): Ditto.
>>        (*addsi3_carry_zext): Ditto.
>>        (*<plusminus_insn>si3_zext_cc_overflow): Ditto.
>>        (*mulsi3_1_zext): Ditto.
>>        (*andsi_1): Ditto.
>>        (*andsi_1_zext): Ditto.
>>        (*andsi_2_zext): Ditto.
>>        (*<any_or:code>si_1_zext): Ditto.
>>        (*<any_or:code>si_2_zext): Ditto.
>>        (*test<mode>_1): Use <general_operand> predicate for operand 1.
>>        (*and<mode>_2): Ditto.
>>        (add->lea splitter): Check operand modes in insn constraint.  Extend
>>        operands less than SImode wide to SImode.
>>        (add->lea zext splitter): Do not extend input operands to DImode.
>>        (*lea_general_1): Handle only QImode and HImode operands.
>>        (*lea_general_2): Ditto.
>>        (*lea_general_3): Ditto.
>>        (*lea_general_1_zext): Remove.
>>        (*lea_general_2_zext): Ditto.
>>        (*lea_general_3_zext): Ditto.
>>        (*lea_general_4): Check operand modes in insn constraint.  Extend
>>        operands less than SImode wide to SImode.
>>        (ashift->lea splitter): Ditto.
>>        * config/i386/i386.c (ix86_print_operand_address): Print address
>>        registers with 'q' modifier on 64bit targets.
>>        * config/i386/predicates.md (pic_32bit_opreand): Define as special
>>        predicate.  Reject non-SI and non-DI modes.
>>
>> Bootstrapped and regression ested on x86_64-pc-linux-gnu {,-m32}.

> GCC and glibc testsuites are clean on x32.  Can you check it in?

I will do this tomorrow, if anybody has some comment on the patch.

Thanks,
Uros.

Reply via email to