[PATCH][AArch64] PR target/71112: Properly create lowpart of pic_offset_table_rtx with -fpie
Kyrill Tkachov
kyrylo.tkachov@foss.arm.com
Tue Nov 29 09:09:00 GMT 2016
Hi all,
This ICE only occurs on big-endian ILP32 -fpie code. The expansion code generates the invalid load:
(insn 6 5 7 (set (reg/f:SI 76)
(unspec:SI [
(mem/u/c:SI (lo_sum:SI (nil)
(symbol_ref:SI ("dbs") [flags 0x40] <var_decl 0x7f6e387c0ab0 dbs>)) [0 S4 A8])
] UNSPEC_GOTSMALLPIC28K))
(expr_list:REG_EQUAL (symbol_ref:SI ("dbs") [flags 0x40] <var_decl 0x7f6e387c0ab0 dbs>)
(nil)))
to load the symbol. Note the (nil) argument to lo_sum.
The buggy hunk meant to take the lowpart of the pic_offset_table_rtx register but it did so by explicitly
constructing a subreg, for which the offset is wrong for big-endian. The right way is to use gen_lowpart which
knows what exactly to do, with this patch we emit:
(insn 6 5 7 (set (reg/f:SI 76)
(unspec:SI [
(mem/u/c:SI (lo_sum:SI (subreg:SI (reg:DI 73) 4)
(symbol_ref:SI ("dbs") [flags 0x40] <var_decl 0x7ffb097e6ab0 dbs>)) [0 S4 A8])
] UNSPEC_GOTSMALLPIC28K))
(expr_list:REG_EQUAL (symbol_ref:SI ("dbs") [flags 0x40] <var_decl 0x7ffb097e6ab0 dbs>)
(nil)))
and everything works fine.
Bootstrapped and tested on aarch64-none-linux-gnu.
Also tested on aarch64_be-none-elf.
Ok for trunk?
Thanks,
Kyrill
2016-11-29 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/71112
* config/aarch64/aarch64.c (aarch64_load_symref_appropriately,
case SYMBOL_SMALL_GOT_28K): Use gen_lowpart rather than constructing
subreg directly.
2016-11-29 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/71112
* gcc.c-torture/compile/pr71112.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aarch64-fpie.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161129/daa59544/attachment.bin>
More information about the Gcc-patches
mailing list