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? Thanks, Martin gcc/ChangeLog: 2019-06-27 Martin Liska <mli...@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 <mli...@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);