[Bug tree-optimization/49709] Bad code gen with -fipa-sra

2011-07-11 Thread pinskia at gmail dot com
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 ATamp;T
On Jul 11, 2011 17:51, ian at airs dot com lt;gcc-bugzi...@gcc.gnu.orggt;
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

  --gt; 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.


[Bug tree-optimization/49709] Bad code gen with -fipa-sra

2011-07-11 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49709

--- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org 2011-07-12 
01:25:00 UTC ---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49519


[Bug tree-optimization/49709] Bad code gen with -fipa-sra

2011-07-11 Thread ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49709

Ian Lance Taylor ian at airs dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||DUPLICATE

--- Comment #3 from Ian Lance Taylor ian at airs dot com 2011-07-12 04:54:14 
UTC ---
Guess I should have updated my sources first.  Sorry about that.

*** This bug has been marked as a duplicate of bug 49519 ***