public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/49709] New: Bad code gen with -fipa-sra
@ 2011-07-12 0:51 ian at airs dot com
2011-07-12 0:58 ` [Bug tree-optimization/49709] " pinskia at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ian at airs dot com @ 2011-07-12 0:51 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/49709] Bad code gen with -fipa-sra
2011-07-12 0:51 [Bug tree-optimization/49709] New: Bad code gen with -fipa-sra ian at airs dot com
@ 2011-07-12 0:58 ` pinskia at gmail dot com
2011-07-12 1:25 ` pinskia at gcc dot gnu.org
2011-07-12 4:54 ` ian at airs dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gmail dot com @ 2011-07-12 0:58 UTC (permalink / raw)
To: gcc-bugs
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-bugzilla@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: 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/49709] Bad code gen with -fipa-sra
2011-07-12 0:51 [Bug tree-optimization/49709] New: Bad code gen with -fipa-sra ian at airs dot com
2011-07-12 0:58 ` [Bug tree-optimization/49709] " pinskia at gmail dot com
@ 2011-07-12 1:25 ` pinskia at gcc dot gnu.org
2011-07-12 4:54 ` ian at airs dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-07-12 1:25 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/49709] Bad code gen with -fipa-sra
2011-07-12 0:51 [Bug tree-optimization/49709] New: Bad code gen with -fipa-sra ian at airs dot com
2011-07-12 0:58 ` [Bug tree-optimization/49709] " pinskia at gmail dot com
2011-07-12 1:25 ` pinskia at gcc dot gnu.org
@ 2011-07-12 4:54 ` ian at airs dot com
2 siblings, 0 replies; 4+ messages in thread
From: ian at airs dot com @ 2011-07-12 4:54 UTC (permalink / raw)
To: gcc-bugs
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 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-12 4:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12 0:51 [Bug tree-optimization/49709] New: Bad code gen with -fipa-sra ian at airs dot com
2011-07-12 0:58 ` [Bug tree-optimization/49709] " pinskia at gmail dot com
2011-07-12 1:25 ` pinskia at gcc dot gnu.org
2011-07-12 4:54 ` ian at airs dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).