public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/49709] Bad code gen with -fipa-sra
Date: Tue, 12 Jul 2011 00:58:00 -0000	[thread overview]
Message-ID: <bug-49709-4-qiMImOABI7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49709-4@http.gcc.gnu.org/bugzilla/>

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&amp;T
On Jul 11, 2011 17:51, ian at airs dot com &lt;gcc-bugzilla@gcc.gnu.org&gt;
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

  --&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.


  reply	other threads:[~2011-07-12  0:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12  0:51 [Bug tree-optimization/49709] New: " ian at airs dot com
2011-07-12  0:58 ` pinskia at gmail dot com [this message]
2011-07-12  1:25 ` [Bug tree-optimization/49709] " pinskia at gcc dot gnu.org
2011-07-12  4:54 ` ian at airs dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49709-4-qiMImOABI7@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).