Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-23 Thread Jakub Jelinek
On Wed, May 17, 2017 at 07:52:38AM +0100, Richard Sandiford wrote: > 2017-05-17 Richard Sandiford > > gcc/ > * tree-ssa-strlen.c (strinfo): Rename the length field to > nonzero_chars. Add a full_string_p field. > (compare_nonzero_chars, zero_length_string_p): New functions. >

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-16 Thread Richard Sandiford
Richard Sandiford writes: > Jakub Jelinek writes: >> Hi! >> >> Note the intent of the pass is to handle the most common cases, it is fine >> if some cases that aren't common aren't handled, it is all about the extra >> complexity vs. how much it helps on real-world code. > > OK. > >> On Sun, May

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-10 Thread Richard Sandiford
Jakub Jelinek writes: > Hi! > > Note the intent of the pass is to handle the most common cases, it is fine > if some cases that aren't common aren't handled, it is all about the extra > complexity vs. how much it helps on real-world code. OK. > On Sun, May 07, 2017 at 10:10:48AM +0100, Richard S

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-10 Thread Jakub Jelinek
Hi! Note the intent of the pass is to handle the most common cases, it is fine if some cases that aren't common aren't handled, it is all about the extra complexity vs. how much it helps on real-world code. On Sun, May 07, 2017 at 10:10:48AM +0100, Richard Sandiford wrote: > I've got most of the

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-07 Thread Richard Sandiford
Jakub Jelinek writes: > On Fri, May 05, 2017 at 01:01:08PM +0100, Richard Sandiford wrote: >> tree-ssa-strlen.c looks for cases in which a string is built up using >> operations like: >> >> memcpy (a, "foo", 4); >> memcpy (a + 3, "bar", 4); >> int x = strlen (a); >> >> As a side-effe

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Martin Sebor
On 05/05/2017 10:32 AM, Jakub Jelinek wrote: On Fri, May 05, 2017 at 10:28:45AM -0600, Martin Sebor wrote: There have been requests for a warning to diagnose invalid uses of character arrays that are not nul-terminated, such as arguments to functions that expect a (nul-terminated) string. For e

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Jeff Law
On 05/05/2017 10:28 AM, Martin Sebor wrote: On 05/05/2017 09:55 AM, Jakub Jelinek wrote: On Fri, May 05, 2017 at 08:50:04AM -0700, Andi Kleen wrote: Richard Sandiford writes: tree-ssa-strlen.c looks for cases in which a string is built up using operations like: memcpy (a, "foo", 4);

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Jakub Jelinek
On Fri, May 05, 2017 at 10:28:45AM -0600, Martin Sebor wrote: > There have been requests for a warning to diagnose invalid uses > of character arrays that are not nul-terminated, such as arguments > to functions that expect a (nul-terminated) string. For example: > > char *p = (char*)malloc (

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Martin Sebor
On 05/05/2017 09:55 AM, Jakub Jelinek wrote: On Fri, May 05, 2017 at 08:50:04AM -0700, Andi Kleen wrote: Richard Sandiford writes: tree-ssa-strlen.c looks for cases in which a string is built up using operations like: memcpy (a, "foo", 4); memcpy (a + 3, "bar", 4); int x = strlen

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Martin Sebor
On 05/05/2017 06:01 AM, Richard Sandiford wrote: tree-ssa-strlen.c looks for cases in which a string is built up using operations like: memcpy (a, "foo", 4); memcpy (a + 3, "bar", 4); int x = strlen (a); As a side-effect, it optimises the non-final memcpys so that they don't include

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Jakub Jelinek
On Fri, May 05, 2017 at 01:01:08PM +0100, Richard Sandiford wrote: > tree-ssa-strlen.c looks for cases in which a string is built up using > operations like: > > memcpy (a, "foo", 4); > memcpy (a + 3, "bar", 4); > int x = strlen (a); > > As a side-effect, it optimises the non-final me

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Jakub Jelinek
On Fri, May 05, 2017 at 08:50:04AM -0700, Andi Kleen wrote: > Richard Sandiford writes: > > > tree-ssa-strlen.c looks for cases in which a string is built up using > > operations like: > > > > memcpy (a, "foo", 4); > > memcpy (a + 3, "bar", 4); > > int x = strlen (a); > > > > As a sid

Re: Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Andi Kleen
Richard Sandiford writes: > tree-ssa-strlen.c looks for cases in which a string is built up using > operations like: > > memcpy (a, "foo", 4); > memcpy (a + 3, "bar", 4); > int x = strlen (a); > > As a side-effect, it optimises the non-final memcpys so that they don't > include the nu

Make tree-ssa-strlen.c handle partial unterminated strings

2017-05-05 Thread Richard Sandiford
tree-ssa-strlen.c looks for cases in which a string is built up using operations like: memcpy (a, "foo", 4); memcpy (a + 3, "bar", 4); int x = strlen (a); As a side-effect, it optimises the non-final memcpys so that they don't include the nul terminator. However, after removing some