From: Martin Liska Date: Thu, 22 Dec 2016 13:09:11 +0000 (+0100) Subject: Fix tree-optimization/78886. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a71dcca81e3bdc9b387a6c6d1496f1f1d414f3d7;p=gcc.git Fix tree-optimization/78886. PR tree-optimization/78886 * gcc.dg/tree-ssa/pr78886.c: New test. PR tree-optimization/78886 * tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS is equal to NULL. From-SVN: r243886 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0b3c84f814d..b09d8fb7f1f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-22 Martin Liska + + PR tree-optimization/78886 + * tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS + is equal to NULL. + 2016-12-22 Jakub Jelinek PR bootstrap/78817 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c63fd5e6e38..c9ab9dec6a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-22 Martin Liska + + PR tree-optimization/78886 + * gcc.dg/tree-ssa/pr78886.c: New test. + 2016-12-22 Georg-Johann Lay PR testsuite/52641 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c new file mode 100644 index 00000000000..97799301547 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void *malloc(unsigned long x); + +void foo(void) +{ + volatile int i; + malloc(1); + i; +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 67075f07e29..4a05725ca7c 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1869,6 +1869,9 @@ handle_builtin_malloc (enum built_in_function bcode, gimple_stmt_iterator *gsi) { gimple *stmt = gsi_stmt (*gsi); tree lhs = gimple_call_lhs (stmt); + if (lhs == NULL_TREE) + return; + gcc_assert (get_stridx (lhs) == 0); int idx = new_stridx (lhs); tree length = NULL_TREE;