This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc 3.4 regression: sched2 moving "may throw" instructions into epilogue
- From: Andrew Haley <aph at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 1 Mar 2004 14:45:11 +0000
- Subject: gcc 3.4 regression: sched2 moving "may throw" instructions into epilogue
g++ is compiling
------------------------------------------------------------------------
typedef struct kkclass;
typedef struct kkclass *jclass;
struct _Jv_VTable
{
jclass clas;
};
jclass
getClass (void *p)
{
_Jv_VTable **dt = (_Jv_VTable **) p;
return (*dt)->clas;
}
------------------------------------------------------------------------
into
_Z8getClassPv:
.LFB2:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
movl 8(%ebp), %edx
popl %ebp
movl (%edx), %eax
movl (%eax), %eax
ret
.LFE2:
where, as you can see, the code for the memory access is moved after
the stack adjustment in the epilogue.
This is despite the fact that this code was compiled with
-fnon-call-exceptions and -fno-omit-frame-pointer.
This causes a runtime failure to catch a null pointer exception.
Insns that may trap must not be move into the epilogue, because stack
unwinding when throwing exceptions will not work correctly.
g++ 3.2.2 does this, which is correct:
_Z8getClassPv:
.LFB2:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
movl 8(%ebp), %eax
movl (%eax), %eax
movl (%eax), %eax
leave
ret
.LFE2:
The movement of the popl %ebp instruction seems to be in sched2.
Compiler options used were -O3 -fno-omit-frame-pointer -fnon-call-exceptions.
Andrew.