> From 2f8ba3418f10b41bb839aadb292447bd757238d0 Mon Sep 17 00:00:00 2001
> From: Martin Liska <mli...@suse.cz>
> Date: Tue, 7 Apr 2020 16:23:27 +0200
> Subject: [PATCH] Allow new/delete operator deletion only for replaceable.
> 
> gcc/ChangeLog:
> 
> 2020-04-07  Martin Liska  <mli...@suse.cz>
> 
>       PR c++/94314
>       * gimple.c (gimple_call_operator_delete_p): Rename to...
>       (gimple_call_replaceable_operator_delete_p): ... this.
>       Use DECL_IS_REPLACEABLE_OPERATOR_DELETE_P.
>       * gimple.h (gimple_call_operator_delete_p): Rename to ...
>       (gimple_call_replaceable_operator_delete_p): ... this.
>       * tree-core.h (tree_function_decl): Add replaceable_operator
>       flag.
>       * tree-ssa-dce.c (mark_all_reaching_defs_necessary_1):
>       Use DECL_IS_REPLACEABLE_OPERATOR_DELETE_P.
>       (propagate_necessity): Use gimple_call_replaceable_operator_delete_p.
>       (eliminate_unnecessary_stmts): Likewise.
>       * tree-streamer-in.c (unpack_ts_function_decl_value_fields):
>       Pack DECL_IS_REPLACEABLE_OPERATOR.
>       * tree-streamer-out.c (pack_ts_function_decl_value_fields):
>       Unpack the field here.
>       * tree.h (DECL_IS_REPLACEABLE_OPERATOR): New.
>       (DECL_IS_REPLACEABLE_OPERATOR_NEW_P): New.
>       (DECL_IS_REPLACEABLE_OPERATOR_DELETE_P): New.
>       * cgraph.c (cgraph_node::dump): Dump if an operator is replaceable.
>       * ipa-icf.c (sem_item::compare_referenced_symbol_properties): Compare
>       replaceable operator flags.
> 
> gcc/cp/ChangeLog:
> 
> 2020-04-07  Martin Liska  <mli...@suse.cz>
> 
>       PR c++/94314
>       * decl.c (duplicate_decls): Duplicate also DECL_IS_REPLACEABLE_OPERATOR.
>       (cxx_init_decl_processing): Mark replaceable all implicitly defined
>       operators.
> 
> gcc/lto/ChangeLog:
> 
> 2020-04-07  Martin Liska  <mli...@suse.cz>
> 
>       PR c++/94314
>       * lto-common.c (compare_tree_sccs_1): Compare also
>       DECL_IS_REPLACEABLE_OPERATOR.
> 
> gcc/testsuite/ChangeLog:
> 
> 2020-04-07  Martin Liska  <mli...@suse.cz>
> 
>       PR c++/94314
>       * g++.dg/pr94314-2.C: New test.
>       * g++.dg/pr94314-3.C: New test.
>       * g++.dg/pr94314.C: New test.
> @@ -2368,6 +2368,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool 
> newdecl_is_friend)
>           DECL_SET_IS_OPERATOR_NEW (newdecl, true);
>         DECL_LOOPING_CONST_OR_PURE_P (newdecl)
>           |= DECL_LOOPING_CONST_OR_PURE_P (olddecl);
> +       DECL_IS_REPLACEABLE_OPERATOR (newdecl)
> +         |= DECL_IS_REPLACEABLE_OPERATOR (olddecl);
>  
>         if (merge_attr)
>           merge_attribute_bits (newdecl, olddecl);

I think you will also need to take care of decl copying tht happens in
the midle-end.  If we do ipa-cp clone of the replaceable operator I
guess we want to copy the flag since it is still new/delete
(removeing it in dce has still the same semantics)

However if we split the function, I think we want to remove the flag
from foo.part clone, or one would be able to again produce the examples
with broken reference counting by making ipa-split to separate the
refernece count and tail of the function.

I am not quite sure about the offloading done by openMP - I think that
one produces new decls.

Honza

Reply via email to