This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR26983
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Sep 2006 08:03:23 +0200
- Subject: Re: [PATCH] PR26983
- References: <200609101756.35927.steven@gcc.gnu.org>
> 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:
http://gcc.gnu.org/ml/gcc/2006-06/msg00577.html
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