RE: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix

2017-04-20 Thread Matthew Fortune
Jakub Jelinek  writes:
> On Thu, Apr 20, 2017 at 12:49:49PM +, Matthew Fortune wrote:
> > Hi Jeff,
> >
> > I missed a load of test failures while on vacation and just noticed
> > that the fix you did for a potentially uninitialized variable warning
> > is overwriting the stack and breaking MSA in MIPS.
> >
> > I guess you may have intended to set the length appropriately and only
> > zero the elements that would not be set in the loop:
> >
> > memset (_perm[nelt], 0, MAX_VECT_LEN - nelt);
> >
> > but I switched it to just zero initialise the whole array for
> > simplicity in the patch below.
> >
> > I thought I'd check with you before committing. Obviously I'd like to
> > apply this to GCC 7 branch as well.
> 
> As it is just 16, it is not a big deal either way, memsetting everything
> might be even faster.  If it would be bigger than that, the MAX_VECT_LEN
> - nelt case would be better.
> 
> > gcc/
> > * config/mips/mips.c (mips_expand_vec_perm_const): Re-fix
> > uninitialized variable warning to avoid buffer overrun.
> 
> Ok, thanks, even for GCC 7 branch.

Thanks Jakub. Committed on trunk and gcc-7-branch.

Matthew


Re: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix

2017-04-20 Thread Jakub Jelinek
On Thu, Apr 20, 2017 at 12:49:49PM +, Matthew Fortune wrote:
> Hi Jeff,
> 
> I missed a load of test failures while on vacation and just noticed
> that the fix you did for a potentially uninitialized variable warning
> is overwriting the stack and breaking MSA in MIPS.
> 
> I guess you may have intended to set the length appropriately and
> only zero the elements that would not be set in the loop:
> 
> memset (_perm[nelt], 0, MAX_VECT_LEN - nelt);
> 
> but I switched it to just zero initialise the whole array for
> simplicity in the patch below.
> 
> I thought I'd check with you before committing. Obviously I'd like to
> apply this to GCC 7 branch as well.

As it is just 16, it is not a big deal either way, memsetting everything
might be even faster.  If it would be bigger than that, the MAX_VECT_LEN -
nelt case would be better.

> gcc/
>   * config/mips/mips.c (mips_expand_vec_perm_const): Re-fix
>   uninitialized variable warning to avoid buffer overrun.

Ok, thanks, even for GCC 7 branch.

Jakub