public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/53040] New: nested functions may trash floating point registers
@ 2012-04-19 11:11 amodra at gmail dot com
  2012-04-19 15:32 ` [Bug target/53040] " amodra at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2012-04-19 11:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

             Bug #: 53040
           Summary: nested functions may trash floating point registers
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amodra@gmail.com


compile with -m32 -Os -fno-inline
void ws_f (void)
{
  char b[10];
  void ns_f (void)
  {
    char a[33];
    __asm __volatile ("#%0 %1" : "=m" (a), "=m" (b) : : "fr28", "fr31");
  }
  ns_f ();
}

results in

ns_f.2345:
        stwu 1,-96(1)
        mflr 0
        stfd 28,64(1)
        stw 0,100(1)
        stfd 31,88(1)
[snip]
        addi 11,1,96
        b _restfpr_28_x

_restfpr_28_x will restore fr29 and fr30 from uninitialised stack.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
@ 2012-04-19 15:32 ` amodra at gmail dot com
  2012-04-19 15:40 ` amodra at gmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2012-04-19 15:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #1 from Alan Modra <amodra at gmail dot com> 2012-04-19 15:24:30 UTC ---
Created attachment 27191
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27191
obvious fix


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
  2012-04-19 15:32 ` [Bug target/53040] " amodra at gmail dot com
@ 2012-04-19 15:40 ` amodra at gmail dot com
  2012-04-20  9:34 ` amodra at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2012-04-19 15:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-04-19
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
  2012-04-19 15:32 ` [Bug target/53040] " amodra at gmail dot com
  2012-04-19 15:40 ` amodra at gmail dot com
@ 2012-04-20  9:34 ` amodra at gcc dot gnu.org
  2013-02-06  2:40 ` amodra at gmail dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu.org @ 2012-04-20  9:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #2 from Alan Modra <amodra at gcc dot gnu.org> 2012-04-20 09:33:23 UTC ---
Author: amodra
Date: Fri Apr 20 09:33:19 2012
New Revision: 186616

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186616
Log:
    PR target/53040
    * config/rs6000/rs6000.c (rs6000_savres_strategy): When using
    static chain, set REST_INLINE_FPRS too.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (2 preceding siblings ...)
  2012-04-20  9:34 ` amodra at gcc dot gnu.org
@ 2013-02-06  2:40 ` amodra at gmail dot com
  2013-02-06  2:47 ` amodra at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2013-02-06  2:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Alan Modra <amodra at gmail dot com> 2013-02-06 02:39:54 UTC ---
Fixed.  Not a regression so not applying to FSF branches.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (3 preceding siblings ...)
  2013-02-06  2:40 ` amodra at gmail dot com
@ 2013-02-06  2:47 ` amodra at gcc dot gnu.org
  2013-02-06 11:50 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu.org @ 2013-02-06  2:47 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #4 from Alan Modra <amodra at gcc dot gnu.org> 2013-02-06 02:46:24 UTC ---
Author: amodra
Date: Wed Feb  6 02:46:13 2013
New Revision: 195778

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195778
Log:
    PR target/53040
    * config/rs6000/rs6000.c (rs6000_savres_strategy): When using
    static chain, set REST_INLINE_FPRS too.


Modified:
    branches/ibm/gcc-4_7-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-4_7-branch/gcc/config/rs6000/rs6000.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (4 preceding siblings ...)
  2013-02-06  2:47 ` amodra at gcc dot gnu.org
@ 2013-02-06 11:50 ` ebotcazou at gcc dot gnu.org
  2013-02-06 13:32 ` amodra at gmail dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2013-02-06 11:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-02-06 11:49:59 UTC ---
Can you reconsider?  If that's an obvious fix for an annoying target problem,
then it should be put at least on the 4.7 branch.  There are plenty of
precedents for other targets (x86, SPARC, ARM, etc).


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (5 preceding siblings ...)
  2013-02-06 11:50 ` ebotcazou at gcc dot gnu.org
@ 2013-02-06 13:32 ` amodra at gmail dot com
  2013-02-06 16:46 ` ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gmail dot com @ 2013-02-06 13:32 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #6 from Alan Modra <amodra at gmail dot com> 2013-02-06 13:31:45 UTC ---
This one is hardly an annoying bug.  You need
a) nested functions,
b) using floating point,
c) with an unusual set of callee saved fprs,
d) and -Os.

I found the bug only because I wrote a fairly complete test for
prologue/epilogue code.

OTOH, the patch is quite obvious and completely safe..


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (6 preceding siblings ...)
  2013-02-06 13:32 ` amodra at gmail dot com
@ 2013-02-06 16:46 ` ebotcazou at gcc dot gnu.org
  2013-02-06 22:26 ` dje at gcc dot gnu.org
  2013-02-07  1:40 ` amodra at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2013-02-06 16:46 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-02-06 16:45:44 UTC ---
> This one is hardly an annoying bug.  You need
> a) nested functions,
> b) using floating point,
> c) with an unusual set of callee saved fprs,
> d) and -Os.

a) + b) + d) is pretty much standard e.g. for embedded Ada on PowerPC/VxWorks.

> OTOH, the patch is quite obvious and completely safe..

Then I think it's a good candidate for a backport onto the 4.7 branch.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (7 preceding siblings ...)
  2013-02-06 16:46 ` ebotcazou at gcc dot gnu.org
@ 2013-02-06 22:26 ` dje at gcc dot gnu.org
  2013-02-07  1:40 ` amodra at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: dje at gcc dot gnu.org @ 2013-02-06 22:26 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at gcc dot gnu.org

--- Comment #8 from David Edelsohn <dje at gcc dot gnu.org> 2013-02-06 22:25:21 UTC ---
Go ahead and backport it to 4.7 branch.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/53040] nested functions may trash floating point registers
  2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
                   ` (8 preceding siblings ...)
  2013-02-06 22:26 ` dje at gcc dot gnu.org
@ 2013-02-07  1:40 ` amodra at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu.org @ 2013-02-07  1:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53040

--- Comment #9 from Alan Modra <amodra at gcc dot gnu.org> 2013-02-07 01:39:29 UTC ---
Author: amodra
Date: Thu Feb  7 01:39:21 2013
New Revision: 195834

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195834
Log:
    PR target/53040
    * config/rs6000/rs6000.c (rs6000_savres_strategy): When using
    static chain, set REST_INLINE_FPRS too.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/rs6000/rs6000.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-02-07  1:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-19 11:11 [Bug target/53040] New: nested functions may trash floating point registers amodra at gmail dot com
2012-04-19 15:32 ` [Bug target/53040] " amodra at gmail dot com
2012-04-19 15:40 ` amodra at gmail dot com
2012-04-20  9:34 ` amodra at gcc dot gnu.org
2013-02-06  2:40 ` amodra at gmail dot com
2013-02-06  2:47 ` amodra at gcc dot gnu.org
2013-02-06 11:50 ` ebotcazou at gcc dot gnu.org
2013-02-06 13:32 ` amodra at gmail dot com
2013-02-06 16:46 ` ebotcazou at gcc dot gnu.org
2013-02-06 22:26 ` dje at gcc dot gnu.org
2013-02-07  1:40 ` amodra at gcc dot gnu.org

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