From fc5e7d2ac42fbc9169458095f4fff257e4a80d03 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 29 Jul 2019 12:39:46 +0200 Subject: [PATCH] Fix ICE seen in tree-ssa-dce.c for new/delete pair. 2019-07-29 Martin Liska * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not remove LHS of operator new call. It's handled latter. 2019-07-29 Martin Liska * g++.dg/cpp1y/new1.C (test_unused): Add new case that causes ICE. From-SVN: r273875 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/new1.C | 8 ++++++++ gcc/tree-ssa-dce.c | 13 +++++++------ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 01e4666051d..6ef0bd5fd66 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-29 Martin Liska + + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not + remove LHS of operator new call. It's handled latter. + 2019-07-29 Richard Biener PR tree-optimization/91267 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30671620e43..e3879924487 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-29 Martin Liska + + * g++.dg/cpp1y/new1.C (test_unused): Add new case that causes + ICE. + 2019-07-29 Richard Biener PR tree-optimization/91267 diff --git a/gcc/testsuite/g++.dg/cpp1y/new1.C b/gcc/testsuite/g++.dg/cpp1y/new1.C index a95dd4d1ee3..5e4f1bf6b0b 100644 --- a/gcc/testsuite/g++.dg/cpp1y/new1.C +++ b/gcc/testsuite/g++.dg/cpp1y/new1.C @@ -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"} } */ diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 17a8d5e2eee..763b76f0e53 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -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)) -- 2.30.2