aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2017-04-29 16:39:25 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2017-04-29 14:39:25 +0000
commit4212aecdf8c4bd99b681fcfc2396844303bab39d (patch)
tree003459e0c47e58a983513c0fb523ccb389c52f19 /gcc
parentfe75f73248425f0f4c0d2196811ce1d7afb9c09f (diff)
downloadgcc-4212aecdf8c4bd99b681fcfc2396844303bab39d.zip
gcc-4212aecdf8c4bd99b681fcfc2396844303bab39d.tar.gz
gcc-4212aecdf8c4bd99b681fcfc2396844303bab39d.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/strncpy-1.c16
-rw-r--r--gcc/tree-ssa-alias.c2
4 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a208292..3e34747 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 59f1a31..2d3d02b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/strncpy-1.c b/gcc/testsuite/gcc.dg/tree-ssa/strncpy-1.c
new file mode 100644
index 0000000..751eaea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/strncpy-1.c
@@ -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" } } */
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 0dcb273..8cab159 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -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. */