tree-ssa-dse.c (initialize_ao_ref_for_dse): Handle _chk variants of memcpy, memmove...
authorJeff Law <law@redhat.com>
Wed, 26 Jun 2019 18:00:00 +0000 (12:00 -0600)
committerJeff Law <law@gcc.gnu.org>
Wed, 26 Jun 2019 18:00:00 +0000 (12:00 -0600)
* tree-ssa-dse.c (initialize_ao_ref_for_dse): Handle _chk variants of
memcpy, memmove and memset builtins.
(maybe_trim_memstar_call): Likewise.

* gcc.c-torture/execute/builtins/builtins.exp: Add -fno-tree-dse
as DSE compromises several of these tests.
* gcc.dg/builtin-stringop-chk-1.c: Similarly.
* gcc.dg/memcpy-2.c: Similarly.
* gcc.dg/pr40340-1.c: Similarly.
* gcc.dg/pr40340-2.c: Similarly.
* gcc.dg/pr40340-5.c: Similarly.

From-SVN: r272704

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
gcc/testsuite/gcc.dg/builtin-stringop-chk-1.c
gcc/testsuite/gcc.dg/memcpy-2.c
gcc/testsuite/gcc.dg/pr40340-1.c
gcc/testsuite/gcc.dg/pr40340-2.c
gcc/testsuite/gcc.dg/pr40340-5.c
gcc/tree-ssa-dse.c

index c039e62ccef89c44f9c6c6ae9e16b49a043d048e..af5afa638b6d0940d75a6d8313c1ff18707ee2f9 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-26  Jeff Law  <law@redhat.com>
+
+       * tree-ssa-dse.c (initialize_ao_ref_for_dse): Handle _chk variants of
+       memcpy, memmove and memset builtins.
+       (maybe_trim_memstar_call): Likewise.
+
 2019-06-26  David Edelsohn  <dje.gcc@gmail.com>
 
        * config/rs6000/rs6000-logue.c: Add #ifndef TARGET_PROFILE_KERNEL.
index e53ebc199b4cb14f039af1ee1dc7a03ebaea9d93..eb9f6cc9921e69535b25126b9b6127dfc10ddab2 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-26  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/execute/builtins/builtins.exp: Add -fno-tree-dse
+       as DSE compromises several of these tests.
+       * gcc.dg/builtin-stringop-chk-1.c: Similarly.
+       * gcc.dg/memcpy-2.c: Similarly.
+       * gcc.dg/pr40340-1.c: Similarly.
+       * gcc.dg/pr40340-2.c: Similarly.
+       * gcc.dg/pr40340-5.c: Similarly.
+
 2019-06-26  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR Fortran/90988
index 5e899d5e31e7a8d58585f750efcc67311b0cabf1..fb9d3ece181fee3489e1ddd2f72f40dbbf807bb6 100644 (file)
@@ -37,7 +37,7 @@ load_lib c-torture.exp
 torture-init
 set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
 
-set additional_flags "-fno-tree-loop-distribute-patterns -fno-tracer"
+set additional_flags "-fno-tree-dse -fno-tree-loop-distribute-patterns -fno-tracer"
 if [istarget "powerpc-*-darwin*"] {
    lappend additional_flags "-Wl,-multiply_defined,suppress"
 }
index afd07ddd08ddce6301286390cf0d6d4a839170af..40cfa0472901ff35ae0f6fb929133158ce80f3c9 100644 (file)
@@ -1,7 +1,7 @@
 /* Test whether buffer overflow warnings for __*_chk builtins
    are emitted properly.  */
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wno-format -std=gnu99 -ftrack-macro-expansion=0" } */
+/* { dg-options "-O2 -Wno-format -std=gnu99 -ftrack-macro-expansion=0 -fno-tree-dse" } */
 // { dg-skip-if "packed attribute missing for t" { "epiphany-*-*" } }
 
 extern void abort (void);
index 7f839d27abde09668a9e7620c36bc8e951957e52..6ad887416e3ae9cea842e07084d9366dffab4291 100644 (file)
@@ -1,6 +1,6 @@
 /* PR middle-end/38454 */
 /* { dg-do compile } */
-/* { dg-options "-O2" } */
+/* { dg-options "-O2 -fno-tree-dse" } */
 
 typedef __SIZE_TYPE__ size_t;
 
index 8fbb206a21e251ec1da58467b20a343756efd5fa..6307e064c3d1a5754e8daef643caf0de7d52bd4c 100644 (file)
@@ -1,6 +1,6 @@
 /* PR middle-end/40340 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wall -Wno-system-headers" } */
+/* { dg-options "-O2 -Wall -Wno-system-headers -fno-tree-dse" } */
 
 #include "pr40340.h"
 
index 10083acd10273bf5121f50c12d3c2ec6d98e53f3..ea76e10082d7658ac0a6551a112ff69c7dbad7be 100644 (file)
@@ -1,6 +1,6 @@
 /* PR middle-end/40340 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wall -Wno-system-headers" } */
+/* { dg-options "-O2 -Wall -Wno-system-headers -fno-tree-dse" } */
 
 #include "pr40340.h"
 
index 0e48a2ca943c53cf232150b6e679abf420876bf0..99e58f2ab7ff28f91eb9aa64a174f3ddd761fb2b 100644 (file)
@@ -1,6 +1,6 @@
 /* PR middle-end/40340 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wall -Wsystem-headers -g" } */
+/* { dg-options "-O2 -Wall -Wsystem-headers -g -fno-tree-dse" } */
 
 #define TEST3
 #include "pr40340.h"
index aa998f416c76eda8f327255d3c00bffc6ddb632c..ea71f49ef8ca614743fddf3ef13e6568eba86122 100644 (file)
@@ -98,6 +98,9 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write)
          case BUILT_IN_MEMCPY:
          case BUILT_IN_MEMMOVE:
          case BUILT_IN_MEMSET:
+         case BUILT_IN_MEMCPY_CHK:
+         case BUILT_IN_MEMMOVE_CHK:
+         case BUILT_IN_MEMSET_CHK:
            {
              tree size = NULL_TREE;
              if (gimple_call_num_args (stmt) == 3)
@@ -434,6 +437,8 @@ maybe_trim_memstar_call (ao_ref *ref, sbitmap live, gimple *stmt)
     {
     case BUILT_IN_MEMCPY:
     case BUILT_IN_MEMMOVE:
+    case BUILT_IN_MEMCPY_CHK:
+    case BUILT_IN_MEMMOVE_CHK:
       {
        int head_trim, tail_trim;
        compute_trims (ref, live, &head_trim, &tail_trim, stmt);
@@ -455,6 +460,7 @@ maybe_trim_memstar_call (ao_ref *ref, sbitmap live, gimple *stmt)
       }
 
     case BUILT_IN_MEMSET:
+    case BUILT_IN_MEMSET_CHK:
       {
        int head_trim, tail_trim;
        compute_trims (ref, live, &head_trim, &tail_trim, stmt);
@@ -860,6 +866,9 @@ dse_dom_walker::dse_optimize_stmt (gimple_stmt_iterator *gsi)
          case BUILT_IN_MEMCPY:
          case BUILT_IN_MEMMOVE:
          case BUILT_IN_MEMSET:
+         case BUILT_IN_MEMCPY_CHK:
+         case BUILT_IN_MEMMOVE_CHK:
+         case BUILT_IN_MEMSET_CHK:
            {
              /* Occasionally calls with an explicit length of zero
                 show up in the IL.  It's pointless to do analysis