This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR26983

> This is my proposed fix for PR26983, a P1 regression present in all GCC4
> releases and on the trunk.  The test case is quite simple:
> -------------------------------------
> void* jmpbuf[6];
> void foo()
> {
>     __builtin_setjmp (jmpbuf);
> }
> -------------------------------------
> What happens is this:
> 1. expand_builtin_setjmp creates a setjmp setup and a setjmp receiver.
>    Just before the receiver, it emits a label.  This label has no edges
>    coming in to it, because setjmp is not represented in the CFG.
> 2. In the very first CFG cleanup at the RTL level, cleanup_cfg notices
>    that the basic block with said label has no incoming edges, and so
>    it decides that the block is not reachable and should be removed.

It's only the tip of the iceberg.  __builtin_setjmp/__builtin_longjmp is 
totally broken in GCC 4.x at anything else than -O0, see for example:

We're about to submit a patch to repair it for GCC 4.2 because the Ada 
compiler does rely on it for proper operation, as explained in the head 
comment of expand_builtin_setjmp:

/* __builtin_setjmp is passed a pointer to an array of five words (not
   all will be used on all machines).  It operates similarly to the C
   library function of the same name, but is more efficient.  Much of
   the code below (and for longjmp) is copied from the handling of
   non-local gotos.

   NOTE: This is intended for use by GNAT and the exception handling
   scheme in the compiler and will only work in the method used by
   them.  */

Eric Botcazou

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]