http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49709
--- Comment #1 from pinskia at gmail dot com <pinskia at gmail dot com> 2011-07-12 00:58:13 UTC --- Hmmm. There was just a recent patch to the tail call area which was supposed to fix a testcase like this. Sent from my Palm Pre on AT&T On Jul 11, 2011 17:51, ian at airs dot com <gcc-bugzi...@gcc.gnu.org> wrote: 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: unassig...@gcc.gnu.org ReportedBy: i...@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.