public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14381] New: [3.3/3.4/3.5 Regression] sched2 moving "may throw" instructions into epilogue
@ 2004-03-02 10:23 aph at gcc dot gnu dot org
  2004-03-02 15:22 ` [Bug optimization/14381] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: aph at gcc dot gnu dot org @ 2004-03-02 10:23 UTC (permalink / raw)
  To: gcc-bugs

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.

-- 
           Summary: [3.3/3.4/3.5 Regression] sched2 moving "may throw"
                    instructions into epilogue
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aph at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2004-03-10 17:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-02 10:23 [Bug optimization/14381] New: [3.3/3.4/3.5 Regression] sched2 moving "may throw" instructions into epilogue aph at gcc dot gnu dot org
2004-03-02 15:22 ` [Bug optimization/14381] " pinskia at gcc dot gnu dot org
2004-03-06 11:20 ` ebotcazou at gcc dot gnu dot org
2004-03-10 17:19 ` cvs-commit at gcc dot gnu dot org
2004-03-10 17:27 ` aph at gcc dot gnu dot org
2004-03-10 17:42 ` cvs-commit at gcc dot gnu dot org
2004-03-10 17:58 ` cvs-commit at gcc dot gnu dot org
2004-03-10 17:59 ` aph at gcc dot gnu dot 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).