diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-06-30 20:45:18 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-06-30 20:45:18 +0200 |
commit | 55a0f21aba28fac542ec1b092089140f00eec2ed (patch) | |
tree | 346cd525dca5b49ae36a4d5075a82d931b2cc902 /gcc | |
parent | 6245ad72d23867f979d0960bdde9a8427c6ba262 (diff) | |
download | gcc-55a0f21aba28fac542ec1b092089140f00eec2ed.zip gcc-55a0f21aba28fac542ec1b092089140f00eec2ed.tar.gz gcc-55a0f21aba28fac542ec1b092089140f00eec2ed.tar.bz2 |
re PR tree-optimization/71707 (ICE in get_stridx_plus_constant)
PR tree-optimization/71707
* tree-ssa-strlen.c (get_stridx_plus_constant): Handle already present
strinfo even for ADDR_EXPR ptr.
* gcc.dg/strlenopt-29.c: New test.
From-SVN: r237889
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt-29.c | 27 | ||||
-rw-r--r-- | gcc/tree-ssa-strlen.c | 10 |
4 files changed, 44 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2b27fab..7bdcb07 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-30 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/71707 + * tree-ssa-strlen.c (get_stridx_plus_constant): Handle already present + strinfo even for ADDR_EXPR ptr. + 2016-06-30 Kelvin Nilsen <kelvin@gcc.gnu.org> * config/rs6000/altivec.md (darn_32): Change the condition to diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1f181dc..ac86ece 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-06-30 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/71707 + * gcc.dg/strlenopt-29.c: New test. + PR fortran/71704 * gfortran.dg/gomp/pr71704.f90: New test. diff --git a/gcc/testsuite/gcc.dg/strlenopt-29.c b/gcc/testsuite/gcc.dg/strlenopt-29.c new file mode 100644 index 0000000..fb4b4c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt-29.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/71707 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +char a[32]; +size_t b; + +__attribute__((noinline, noclone)) char * +foo (void) +{ + char *p = memcpy (a, "a", 2) + 1; + memcpy (&a[1], "b", 2); + b = strlen (a) + strlen (&a[1]) + strlen (p); + return p; +} + +int +main () +{ + if (foo () != &a[1] || b != 4) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */ diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 232594b..489c8f0 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -677,8 +677,14 @@ get_stridx_plus_constant (strinfo *basesi, HOST_WIDE_INT off, tree ptr) { if (r == 0) { - gcc_assert (TREE_CODE (ptr) == SSA_NAME); - ssa_ver_to_stridx[SSA_NAME_VERSION (ptr)] = si->idx; + if (TREE_CODE (ptr) == SSA_NAME) + ssa_ver_to_stridx[SSA_NAME_VERSION (ptr)] = si->idx; + else + { + int *pidx = addr_stridxptr (TREE_OPERAND (ptr, 0)); + if (pidx != NULL && *pidx == 0) + *pidx = si->idx; + } return si->idx; } break; |