c++: Optimize in maybe_clone_body aliases even when not at_eof [PR113208]
commit6ad7ca1bb905736c0f57688e93e9e77cbc71a325
authorJakub Jelinek <jakub@redhat.com>
Wed, 15 May 2024 16:50:11 +0000 (15 18:50 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 15 May 2024 16:50:11 +0000 (15 18:50 +0200)
tree462a6eb20f8534da6f2023bd6313e406af4e6102
parent0b93a0ae153ef70a82ff63e67926a01fdab9956b
c++: Optimize in maybe_clone_body aliases even when not at_eof [PR113208]

This patch reworks the cdtor alias optimization, such that we can create
aliases even when maybe_clone_body is called not at at_eof time, without trying
to repeat it in maybe_optimize_cdtor.

2024-05-15  Jakub Jelinek  <jakub@redhat.com>
    Jason Merrill  <jason@redhat.com>

PR lto/113208
* cp-tree.h (maybe_optimize_cdtor): Remove.
* decl2.cc (tentative_decl_linkage): Call maybe_make_one_only
for implicit instantiations of maybe in charge ctors/dtors
declared inline.
(import_export_decl): Don't call maybe_optimize_cdtor.
(c_parse_final_cleanups): Formatting fixes.
* optimize.cc (can_alias_cdtor): Adjust condition, for
HAVE_COMDAT_GROUP && DECL_ONE_ONLY && DECL_WEAK return true even
if not DECL_INTERFACE_KNOWN.
(maybe_clone_body): Don't clear DECL_SAVED_TREE, instead set it
to void_node.
(maybe_clone_body): Remove.
* decl.cc (cxx_comdat_group): For DECL_CLONED_FUNCTION_P
functions if SUPPORTS_ONE_ONLY return DECL_COMDAT_GROUP if already
set.

* g++.dg/abi/comdat3.C: New test.
* g++.dg/abi/comdat4.C: New test.
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/decl2.cc
gcc/cp/optimize.cc
gcc/testsuite/g++.dg/abi/comdat3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/comdat4.C [new file with mode: 0644]