Add st[pr]ncpy to stmt_kills_ref_p

2017-04-29  Marc Glisse  <marc.glisse@inria.fr>

	PR tree-optimization/80487
gcc/
	* tree-ssa-alias.c (stmt_kills_ref_p): Handle stpncpy and strncpy.

gcc/testsuite/
	* gcc.dg/tree-ssa/strncpy-1.c: New file.

From-SVN: r247408
This commit is contained in:
Marc Glisse 2017-04-29 16:39:25 +02:00 committed by Marc Glisse
parent fe75f73248
commit 4212aecdf8
4 changed files with 28 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2017-04-29 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/80487
* tree-ssa-alias.c (stmt_kills_ref_p): Handle stpncpy and strncpy.
2017-04-29 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/79697

View file

@ -1,3 +1,8 @@
2017-04-29 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/80487
* gcc.dg/tree-ssa/strncpy-1.c: New file.
2017-04-29 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/79697

View file

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
void sink (void*);
void f (const char *s)
{
char a[256];
__builtin_memset (a, 0, sizeof a); // redundant memset
__builtin_strncpy (a, s, sizeof a);
sink (a);
}
/* { dg-final { scan-tree-dump-not "memset" "optimized" } } */

View file

@ -2538,6 +2538,8 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref)
case BUILT_IN_MEMPCPY_CHK:
case BUILT_IN_MEMMOVE_CHK:
case BUILT_IN_MEMSET_CHK:
case BUILT_IN_STRNCPY:
case BUILT_IN_STPNCPY:
{
/* For a must-alias check we need to be able to constrain
the access properly. */