Fix ICE seen in tree-ssa-dce.c for new/delete pair.
authorMartin Liska <mliska@suse.cz>
Mon, 29 Jul 2019 10:39:46 +0000 (12:39 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 29 Jul 2019 10:39:46 +0000 (10:39 +0000)
2019-07-29  Martin Liska  <mliska@suse.cz>

* tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not
remove LHS of operator new call.  It's handled latter.
2019-07-29  Martin Liska  <mliska@suse.cz>

* g++.dg/cpp1y/new1.C (test_unused): Add new case that causes
ICE.

From-SVN: r273875

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/new1.C
gcc/tree-ssa-dce.c

index 01e4666051d9c96cd43e135e71dda990f063f6a9..6ef0bd5fd6697c902247dd57cad534723d8f10de 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-29  Martin Liska  <mliska@suse.cz>
+
+       * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not
+       remove LHS of operator new call.  It's handled latter.
+
 2019-07-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/91267
index 30671620e437f12cc2fd591d660a53addc052b2b..e387992448766b0772712dea80b3203c0bdc3169 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-29  Martin Liska  <mliska@suse.cz>
+
+       * g++.dg/cpp1y/new1.C (test_unused): Add new case that causes
+       ICE.
+
 2019-07-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/91267
index a95dd4d1ee3173abc4de4cfbdc512d59d39fe0a2..5e4f1bf6b0ba40db1a927fb2e154e314319f1643 100644 (file)
@@ -61,5 +61,13 @@ new_array_load() {
   delete [] x;
 }
 
+void
+test_unused() {
+  volatile double d = 0.0;
+  double *p = new double ();
+  d += 1.0;
+  delete p;
+}
+
 /* { dg-final { scan-tree-dump-times "Deleting : operator delete" 5 "cddce1"} } */
 /* { dg-final { scan-tree-dump-times "Deleting : _\\d+ = operator new" 7 "cddce1"} } */
index 17a8d5e2eee8d0dd9cf1ba2cfe7eb2991010357b..763b76f0e5325519ff98a1b4036d39c9272ea569 100644 (file)
@@ -1364,12 +1364,13 @@ eliminate_unnecessary_stmts (void)
                     did not mark as necessary, it will confuse the
                     special logic we apply to malloc/free pair removal.  */
                  && (!(call = gimple_call_fndecl (stmt))
-                     || DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL
-                     || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC
-                         && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC
-                         && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC
-                         && !ALLOCA_FUNCTION_CODE_P
-                             (DECL_FUNCTION_CODE (call)))))
+                     || ((DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL
+                          || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC
+                              && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC
+                              && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC
+                              && !ALLOCA_FUNCTION_CODE_P
+                              (DECL_FUNCTION_CODE (call))))
+                         && !DECL_IS_REPLACEABLE_OPERATOR_NEW_P (call))))
                {
                  something_changed = true;
                  if (dump_file && (dump_flags & TDF_DETAILS))