Bug 11304 - [3.3 Regression] Wrong code production with -fomit-frame-pointer
[3.3 Regression] Wrong code production with -fomit-frame-pointer
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: rtl-optimization
3.3
: P2 critical
: 3.3.1
Assigned To: Eric Botcazou
: wrong-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-06-24 07:22 UTC by manuel.serrano
Modified: 2003-07-03 18:09 UTC (History)
1 user (show)

See Also:
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-06-24 10:20:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description manuel.serrano 2003-06-24 07:22:18 UTC
I have found a problem with GCC3.2 and GCC3.3 when -fomit-frame-pointer
and -O2 are both used. The bug seems to be concerning the registers allocation 
that seems erroneous. The problem does not exist with GCC2.95. It goes away
if either -fomit-frame-pointer or -O2 are disabled.


*** Operating system:
=====================
$ uname -a 
Linux owens.inria.fr 2.4.21 #1 Tue Jun 17 16:26:21 CEST 2003 i686 GNU/Linux

*** GCC version:
================
gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.3 (Debian)

*** Source code:
================
int hux(int x){
   if(x){
      foo( 4 );
      return x;
   }
   failure_then_exit(x);
}

*** GCC Command line:
=====================

gcc -O2 -fomit-frame-pointer foo.c

*** Preprocessed source file:
=============================
$ gcc -fomit-frame-pointer foo.c -S -O2 -save-temps
$ cat foo.i 
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"
int hux(int x)
{
   if(x)
   {
      foo( 4 );
      return x;
   }
   failure_then_exit(x);
}


*** Assembly file (that I known you don't want bug that shows the bug):
=======================================================================
$ cat foo.s 
        .file   "foo.c"
        .text
        .p2align 2,,3
.globl hux
        .type   hux, @function
hux:
        pushl   %ebx
        subl    $8, %esp
        movl    16(%esp), %ebx
        testl   %ebx, %ebx
        je      .L2
        subl    $12, %esp
        pushl   $4
        call    foo                    # <-- HERE, THE REGISTER EAX IS NOT
.L3:                                   # RELOADED !!!
        addl    $24, %esp
        popl    %ebx
        ret
        .p2align 2,,3
.L2:
        subl    $12, %esp
        pushl   $0
        call    failure_then_exit
        jmp     .L3
        .size   hux, .-hux
        .ident  "GCC: (GNU) 3.3 (Debian)"
Comment 1 Eric Botcazou 2003-06-24 10:19:32 UTC
Confirmed as a regression from GCC 3.0.4 present on all versions since then.
Comment 2 Andrew Pinski 2003-06-24 11:10:41 UTC
On the mainline (20030623) I get correct code:
tin:~/src/gnu/gcctest>gcc -O2 -fomit-frame-pointer -S -o - pr11304.c -march=i386 -
mtune=i386
        .file   "pr11304.c"
        .text
        .p2align 2,,3
.globl hux
        .type   hux, @function
hux:
        pushl   %ebx
        subl    $8, %esp
        movl    16(%esp), %ebx
        testl   %ebx, %ebx
        je      .L2
        subl    $12, %esp
        pushl   $4
        call    foo
        addl    $16, %esp
        addl    $8, %esp
        movl    %ebx, %eax    ;<--- here eax is reloaded
        popl    %ebx
        ret
        .p2align 2,,3
.L2:
        subl    $12, %esp
        pushl   $0
        call    failure_then_exit
        addl    $16, %esp
        addl    $8, %esp
        popl    %ebx
        ret
        .size   hux, .-hux
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4 20030623 (experimental)"

But in 3.3.1 (20030616), 3.2.2, and 3.2.3, I get the wrong code.
Comment 3 Eric Botcazou 2003-06-24 12:08:01 UTC
Right, I should have said "in all released versions since then".
Comment 5 Eric Botcazou 2003-07-03 18:09:14 UTC
See http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02798.html