Message ID | 902f64c4-1331-dca8-2b1b-3b4c765adfe0@suse.cz |
---|---|
State | New |
Headers | show |
Series | Fix ICE when __builtin_calloc has no LHS (PR tree-optimization/91014). | expand |
On Thu, Jun 27, 2019 at 11:21 AM Martin Liška <mliska@suse.cz> wrote: > > Hi. > > This is quite an obvious changes I've noticed during fuzzing > of s390x target compiler. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? OK. Richard. > Thanks, > Martin > > gcc/ChangeLog: > > 2019-06-27 Martin Liska <mliska@suse.cz> > > PR tree-optimization/91014 > * tree-ssa-dse.c (initialize_ao_ref_for_dse): Bail out > when LHS is NULL_TREE. > > gcc/testsuite/ChangeLog: > > 2019-06-27 Martin Liska <mliska@suse.cz> > > PR tree-optimization/91014 > * gcc.target/s390/pr91014.c: New test. > --- > gcc/testsuite/gcc.target/s390/pr91014.c | 8 ++++++++ > gcc/tree-ssa-dse.c | 5 +++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/s390/pr91014.c > >
Hi! Curious: even if you found the issue on a s390x target, shouldn't this (presumably generic?) test case live in a generic place instead of 'gcc.target/s390/'? Grüße Thomas On 2019-06-27T11:21:33+0200, Martin Liška <mliska@suse.cz> wrote: > This is quite an obvious changes I've noticed during fuzzing > of s390x target compiler. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > 2019-06-27 Martin Liska <mliska@suse.cz> > > PR tree-optimization/91014 > * tree-ssa-dse.c (initialize_ao_ref_for_dse): Bail out > when LHS is NULL_TREE. > > gcc/testsuite/ChangeLog: > > 2019-06-27 Martin Liska <mliska@suse.cz> > > PR tree-optimization/91014 > * gcc.target/s390/pr91014.c: New test. > --- > gcc/testsuite/gcc.target/s390/pr91014.c | 8 ++++++++ > gcc/tree-ssa-dse.c | 5 +++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/s390/pr91014.c > > > diff --git a/gcc/testsuite/gcc.target/s390/pr91014.c b/gcc/testsuite/gcc.target/s390/pr91014.c > new file mode 100644 > index 00000000000..eb37b333b5b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/s390/pr91014.c > @@ -0,0 +1,8 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O" } */ > +/* { dg-require-effective-target alloca } */ > + > +void foo(void) > +{ > + __builtin_calloc (1, 1); /* { dg-warning "ignoring return value of '__builtin_calloc' declared with attribute 'warn_unused_result'" } */ > +} > diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c > index 1b1a9f34230..df05a55ce78 100644 > --- a/gcc/tree-ssa-dse.c > +++ b/gcc/tree-ssa-dse.c > @@ -129,10 +129,11 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write) > { > tree nelem = gimple_call_arg (stmt, 0); > tree selem = gimple_call_arg (stmt, 1); > + tree lhs; > if (TREE_CODE (nelem) == INTEGER_CST > - && TREE_CODE (selem) == INTEGER_CST) > + && TREE_CODE (selem) == INTEGER_CST > + && (lhs = gimple_call_lhs (stmt)) != NULL_TREE) > { > - tree lhs = gimple_call_lhs (stmt); > tree size = fold_build2 (MULT_EXPR, TREE_TYPE (nelem), > nelem, selem); > ao_ref_init_from_ptr_and_size (write, lhs, size);
On 9/24/19 11:14 AM, Thomas Schwinge wrote: > Hi! > > Curious: even if you found the issue on a s390x target, shouldn't this > (presumably generic?) test case live in a generic place instead of > 'gcc.target/s390/'? Sure, that's logical and I've just tested that locally on x86_64-linux-gnu. Ready to be installed? Thanks, Martin > > > Grüße > Thomas
On 9/24/19 4:34 AM, Martin Liška wrote: > On 9/24/19 11:14 AM, Thomas Schwinge wrote: >> Hi! >> >> Curious: even if you found the issue on a s390x target, shouldn't this >> (presumably generic?) test case live in a generic place instead of >> 'gcc.target/s390/'? > > Sure, that's logical and I've just tested that locally on x86_64-linux-gnu. > > Ready to be installed? Sure, and IMHO moving tests like this should be something that can be done without explicit ACKs. jeff
On 9/24/19 5:57 PM, Jeff Law wrote: > Sure, and IMHO moving tests like this should be something that can be > done without explicit ACKs. Ok, next time I'll not ask for a confirmation ;) Thanks, Martin > > jeff
diff --git a/gcc/testsuite/gcc.target/s390/pr91014.c b/gcc/testsuite/gcc.target/s390/pr91014.c new file mode 100644 index 00000000000..eb37b333b5b --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr91014.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target alloca } */ + +void foo(void) +{ + __builtin_calloc (1, 1); /* { dg-warning "ignoring return value of '__builtin_calloc' declared with attribute 'warn_unused_result'" } */ +} diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 1b1a9f34230..df05a55ce78 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -129,10 +129,11 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write) { tree nelem = gimple_call_arg (stmt, 0); tree selem = gimple_call_arg (stmt, 1); + tree lhs; if (TREE_CODE (nelem) == INTEGER_CST - && TREE_CODE (selem) == INTEGER_CST) + && TREE_CODE (selem) == INTEGER_CST + && (lhs = gimple_call_lhs (stmt)) != NULL_TREE) { - tree lhs = gimple_call_lhs (stmt); tree size = fold_build2 (MULT_EXPR, TREE_TYPE (nelem), nelem, selem); ao_ref_init_from_ptr_and_size (write, lhs, size);