Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-16 Thread Eric Botcazou
> But, fails whenever the size of the mode of the save area is bigger than a > certain amount… On my port, the size taken up by the save area is large > enough to cause this to fail. :-( That's a bit unexpected, why do you need so big a save area exactly? The only architecture for which this

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-16 Thread Eric Botcazou
>OK - here is your version of the patch, extended with a comment which > I think is helpful for other people reading the code, and with the > changes to builtins.c and md.texi removed, since the size of the buffer > is not changing. > >Is this version OK to apply ? Yes, IMO that's fine, t

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-16 Thread Nicholas Clifton
Hi Eric, OK - here is your version of the patch, extended with a comment which I think is helpful for other people reading the code, and with the changes to builtins.c and md.texi removed, since the size of the buffer is not changing. Is this version OK to apply ? Cheers Nick gcc/Cha

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-15 Thread Mike Stump
On May 15, 2014, at 12:55 AM, Eric Botcazou wrote: > No, that's too complicated and risky, just do the following: > > /* builtin_setjmp takes a pointer to 5 words or pointers. */ > if (POINTER_SIZE > BITS_PER_WORD) > tmp = size_int (4); > else > tmp = size_int (5 * BIT

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-15 Thread Eric Botcazou
> Ah - you are worried about the case where STACK_SAVEAREA_MODE() is > smaller than Pmode, yes ? No, simply that the modified formula is plain wrong. The code does: tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); tmp = build_index_type (tmp); tmp = build_array_type (ptr_type_node, t

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-14 Thread Nicholas Clifton
Hi Eric, 2014-05-06 Nick Clifton * except.c (init_eh): Fix computation of builtin setjmp buffer size. That's the same patch as https://gcc.gnu.org/ml/gcc-patches/2011-11/msg00272.html and is still incorrect. Ah - you are worried about the case where STACK_SAVEAREA_MODE

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-14 Thread Eric Botcazou
> Now we just need a __builtin_setjmp style of maintainer to review… Let's just do what I suggested in https://gcc.gnu.org/ml/gcc-patches/2011-11/msg00286.html -- Eric Botcazou

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-14 Thread Eric Botcazou
> 2014-05-06 Nick Clifton > > * except.c (init_eh): Fix computation of builtin setjmp buffer > size. That's the same patch as https://gcc.gnu.org/ml/gcc-patches/2011-11/msg00272.html and is still incorrect. -- Eric Botcazou

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-08 Thread Mike Stump
On May 8, 2014, at 7:24 AM, Nicholas Clifton wrote: > > What do you think of this version ? Now we just need a __builtin_setjmp style of maintainer to review…

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-08 Thread Nicholas Clifton
Hi Mike, How about GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)) / GET_MODE_SIZE (Pmode) + 2 + /* slop for mips, see builtin_setjmp_setup */ 1 - 1. This retains the slop for mips, and fixes ports like ia64 and s390 (see STACK_SAVEAREA_MODE on those ports, it is larger one might expect)

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Mike Stump
On May 6, 2014, at 8:07 AM, Nicholas Clifton wrote: > + tmp = size_int ((5 * MAX (POINTER_SIZE, BITS_PER_WORD)) / > BITS_PER_WORD - 1); This is not right. The denominator should either be GET_MODE_SIZE (Pmode) or POINTER_SIZE. See get_nl_goto_field for additional fun. Also, the save are

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nicholas Clifton
Hi Jakub, But what will this do on targets where POINTER_SIZE is smaller than BITS_PER_WORD? E.g. I think some options on s390 or ppc. If you want it to be always 5 pointers, then you want tmp = size_int (4); and not something else, otherwise it really depends on how exactly it is used, perh

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 03:34:37PM +0100, Nicholas Clifton wrote: > --- gcc/except.c (revision 210096) > +++ gcc/except.c (working copy) > @@ -286,8 +286,8 @@ >tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1); > #endif > #else > - /* builtin_setjmp takes a pointer to 5 words.

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 4:34 PM, Nicholas Clifton wrote: > Hi Jakub, > > >>> /* builtin_setjmp takes a pointer to 5 words. */ >>> - tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); >>> + tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1); > > >> That doesn't look correct

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nicholas Clifton
Hi Jakub, /* builtin_setjmp takes a pointer to 5 words. */ - tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1); + tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1); That doesn't look correct to me. If the code wants to create 5 words long array, but with pointer el

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 01:55:18PM +0100, Nick Clifton wrote: > 2014-05-06 Nick Clifton > > * except.c (init_eh): Fix computation of builtin setjmp buffer > size. > > Index: gcc/except.c > === > --- gcc/except.c (

RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nick Clifton
Hi Guys, There is a small bug in the computation for the size of the builtin setjmp buffer. The size is based upon BITS_PER_WORD / POINTER_SIZE which for most targets equates to 1. But for targets where pointers are larger than a word, it equates to zero. This leads to stack corruptio