[Bug tree-optimization/49709] New: Bad code gen with -fipa-sra
ian at airs dot com
gcc-bugzilla@gcc.gnu.org
Tue Jul 12 00:51:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49709
Summary: Bad code gen with -fipa-sra
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: major
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ian@airs.com
Created attachment 24741
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24741
Test case
I have attached a C test case. When compiled for x86 with -m32 -O2, the test
case aborts. When compiled with -m32, or with -m32 -O2 -fno-ipa-sra it runs to
completion.
I believe the bug is that ipa-sra leaves a call which refers to function
parameters using MEM_REF expressions which refer to fields of the parameters.
These are translated into MEM expressions which load the address of the
parameter into a register and then use a MEM_REF to load an offset from that
register. This MEM does not refer to the internal_arg_pointer, but to a
register which was set based on the internal_arg_pointer. That means that
mem_overlaps_already_clobbered_arg_p in calls.c does not recognize that the MEM
refers to the argument area. That in turn means that gcc thinks that it can
make a tail call, but when setting up the arguments for the call it clobbers
arguments that it has yet to read.
The fix may be to make mem_overlaps_already_clobbered_arg_p much smarter, or to
disable tail calls when applying SRA to a function and passes parameters to it.
More information about the Gcc-bugs
mailing list