Fix PR rtl-optimization/60452
Eric Botcazou
ebotcazou@adacore.com
Sun Mar 23 12:21:00 GMT 2014
This is a regression present on mainline and 4.8 branch: ifcvt generates a
conditional move from an invalid location on the stack, resulting in a
segfault at runtime. The testcase is pathological and exploits the very old
RTL semantics (now embodied in may_trap_or_fault_p) of considering that stack
references cannot trap, which is of course wrong for nonsensical offsets.
This is an old issue (the attached testcase distilled by Jakub already fails
with GCC 4.3) and the original testcase is clearly machine-generated, so I
don't think that we need to pessimize the common case for it; instead fixing
this kind of very minor issues on a case-by-case basis is good enough I think.
The attached patch only adds a check in rtx_addr_can_trap_p_1 for nonsensical
offsets against the frame pointer; this is sufficient for both testcases. The
check is supposed to be exact (e.g. it never triggers during a bootstrap) so
it won't pessimize anything. This might be different if the ??? comment is
addressed later but, again, I don't think that we should care at this point.
Tested on x86_64-suse-linux, any objections?
2014-03-23 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/60452
* rtlanal.c (rtx_addr_can_trap_p_1): Fix head comment.
<case REG>: Return 1 for nonsensical offsets from the frame pointer.
2014-03-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/execute/20140323-1.c: New test.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr60452.diff
Type: text/x-patch
Size: 3069 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140323/c5778fb0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr60452.c
Type: text/x-csrc
Size: 103 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140323/c5778fb0/attachment-0001.bin>
More information about the Gcc-patches
mailing list