On 8/7/19 4:12 PM, Richard Biener wrote: > On Wed, Aug 7, 2019 at 2:04 PM Martin Liška <mli...@suse.cz> wrote: >> >> On 8/7/19 12:51 PM, Jakub Jelinek wrote: >>> On Wed, Aug 07, 2019 at 12:44:28PM +0200, Martin Liška wrote: >>>> On 8/7/19 11:51 AM, Richard Biener wrote: >>>>> I think the simplest way to achieve this is to not copy, aka clear, >>>>> DECL_IS_OPERATOR_* when cloning and removing arguments >>>>> (cloning for a constant align argument should be OK for example, as is >>>>> for a constant address). Or simply always when cloning. >>>> >>>> Ok, then I'm suggesting following tested patch. >>>> >>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. >>> >>> What about LAMBDA_FUNCTION, doesn't cloning which changes arguments in any >>> way invalidate that too, i.e. shouldn't it be just >>> FUNCTION_DECL_DECL_TYPE (new_node->decl) = NONE; >> >> Well, how are lambdas involved in the new/delete DCE here? Lambdas with >> removed >> arguments should not interfere here. > > But for coverage where we do > > gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl) > && !DECL_FUNCTION_VERSIONED (current_function_decl) > && !DECL_LAMBDA_FUNCTION_P (current_function_decl)); > > all clones should be considered artificial?
Well, from coverage perspective most of them are fine. > > Anyway, your patch is OK, we can think about lambdas separately. Can you > simplify the DCE code after the patch? I installed the patch and I'm sending the follow up cleanup. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin > > Thanks, > Richard. > >>> instead? On the other side, if the cloning doesn't change arguments in any >>> way, do we still want to clear those flags? >> >> Well, I would consider it safer to drop it always. >> >> Martin >> >>> >>> Jakub >>> >>
>From 9da5bd0a2c81a20807caf9cc6915971067b021c3 Mon Sep 17 00:00:00 2001 From: Martin Liska <mli...@suse.cz> Date: Thu, 8 Aug 2019 09:58:34 +0200 Subject: [PATCH] Clean up dead condition for operators in DCE. gcc/ChangeLog: 2019-08-08 Martin Liska <mli...@suse.cz> * tree-ssa-dce.c (propagate_necessity): We can't reach now operators with no arguments. (eliminate_unnecessary_stmts): Likewise here. --- gcc/tree-ssa-dce.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index afb7bd9dedc..80d5f5c30f7 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -810,11 +810,6 @@ propagate_necessity (bool aggressive) if (is_delete_operator || gimple_call_builtin_p (stmt, BUILT_IN_FREE)) { - /* It can happen that a user delete operator has the pointer - argument optimized out already. */ - if (gimple_call_num_args (stmt) == 0) - continue; - tree ptr = gimple_call_arg (stmt, 0); gimple *def_stmt; tree def_callee; @@ -1328,18 +1323,13 @@ eliminate_unnecessary_stmts (void) || (is_gimple_call (stmt) && gimple_call_operator_delete_p (as_a <gcall *> (stmt))))) { - /* It can happen that a user delete operator has the pointer - argument optimized out already. */ - if (gimple_call_num_args (stmt) > 0) + tree ptr = gimple_call_arg (stmt, 0); + if (TREE_CODE (ptr) == SSA_NAME) { - tree ptr = gimple_call_arg (stmt, 0); - if (TREE_CODE (ptr) == SSA_NAME) - { - gimple *def_stmt = SSA_NAME_DEF_STMT (ptr); - if (!gimple_nop_p (def_stmt) - && !gimple_plf (def_stmt, STMT_NECESSARY)) - gimple_set_plf (stmt, STMT_NECESSARY, false); - } + gimple *def_stmt = SSA_NAME_DEF_STMT (ptr); + if (!gimple_nop_p (def_stmt) + && !gimple_plf (def_stmt, STMT_NECESSARY)) + gimple_set_plf (stmt, STMT_NECESSARY, false); } } -- 2.22.0