Bug 34947 - [4.2 Regression] Clobbered float registers not popped
Summary: [4.2 Regression] Clobbered float registers not popped
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.2.3
: P3 major
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2008-01-23 19:37 UTC by Vincent Riviere
Modified: 2009-03-31 15:03 UTC (History)
1 user (show)

See Also:
Target: m68k-linux
Known to work: 4.1.2 4.3.0
Known to fail: 4.2.3 4.2.5
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Riviere 2008-01-23 19:37:33 UTC
This problem is about functions that push some float registers at the beginning, but forget to pop them at the end. The stack pointer is not adjusted as expected, so the function return to an invalid address.

It appears when the following is true:
- the file is compiled with -m68020-60 -O1 -fomit-frame-pointer
- the function uses floats
- the function is complicated enough to have some float registers backed up on the stack
- there is an early return in the function

The problem appears in the following test case:
$ cat bug.c
volatile float g1;
float g2;

void f(void)
    float i;

    if (g2 >= 0)

    for (i = 0; i < 10; ++i)
        g1 = g2 + i;

$ gcc -S bug.c -o - -m68020-60 -O2 -fomit-frame-pointer
        .globl  f
        .type   f, @function
        fmovm #0x4,-(%sp)
        fmove.s g2,%fp2
        fbnge .L9

We can see that some float registers are backuped at the beginning. Then (g2 >= 0) is checked. If it is the case, the function returns with a simple rts, without restoring the registers, to an invalid address.

This happens in gcc 4.2.2 and gcc-4.2-20080116
Comment 1 Vincent Riviere 2008-02-02 19:14:57 UTC
The bug is still here in the official 4.2.3
Comment 2 Vincent Riviere 2008-02-21 07:34:50 UTC
That patch fixes the problem:
Comment 3 Joseph S. Myers 2008-05-19 20:24:40 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 4 Joseph S. Myers 2009-03-31 15:03:03 UTC
Closing 4.2 branch, fixed in 4.3.