From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BF15B3858D20 for ; Thu, 25 Apr 2024 14:22:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF15B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF15B3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714054979; cv=none; b=dYUfYedqIhlL8kFzsgBzaz48bD/pOLObNxhe8wg7HvsRSUOhPa7wyQsDhJ3mNmh8G1vJKt1wERpuBYtG7rN/9NQoIpSjzjT1iW5ZlpzGUOMkDOvJ1a1e9L+WQVZB+vFhE6in9T/wV9F7sZ1xMVaktqN7Ci3/PNRDOm7INDrROhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714054979; c=relaxed/simple; bh=kUS6RiJ6DI9lFKbAjuDMaiXgkukNVg63x3Yz1LqqGsw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=gGDfh2P1/5404gHdWu2506H9ZMzpP+X1mtA3GswjjfR5VP5pINXF4FqlypX4IPlf4X8IDL5seGtp4mEQho/0F6s9BzYfOcT3t+7RIh9X0UH2/zKJadG9ihAqEViWDOXXt/WnMqsA9GMBljVSd2wv2g9pK38itFkTn/b45n2BXyw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714054976; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=YxDJSvfSb9fPIf6rxHEhavftRbHqEl7RstgWUoedvFA=; b=hrXotcEnaG5wYmIuJBK1ZARHo5QVJ+OHJyL0JgIstJ6Gh+GeafCBuGKTzLLRC00LC94jln gbShzXbXd6TM21lHBMFSuOmTVS41VUIddD1en3FxPZUYF3eGRjny2i9LRpMpMVVYFO/lLN VsHENExWu1UbMgKpgX8eZS+Xilr0vRI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-go3fdHj1P2urO4-ECL_mlw-1; Thu, 25 Apr 2024 10:22:52 -0400 X-MC-Unique: go3fdHj1P2urO4-ECL_mlw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30B7F89A7E5; Thu, 25 Apr 2024 14:22:52 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E54BE492BC7; Thu, 25 Apr 2024 14:22:51 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43PEMoHr1455972 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 16:22:50 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43PEMnJd1455971; Thu, 25 Apr 2024 16:22:49 +0200 Date: Thu, 25 Apr 2024 16:22:49 +0200 From: Jakub Jelinek To: Jason Merrill , Jonathan Wakely , Jan Hubicka , gcc-patches@gcc.gnu.org, Richard Biener , Patrick Palka Subject: Re: [PATCH] c++, v4: Retry the aliasing of base/complete cdtor optimization at import_export_decl time [PR113208] Message-ID: Reply-To: Jakub Jelinek References: <5fe9db40-4bff-4be4-a434-6509133f26e3@redhat.com> <5f6569bc-8d94-434c-b66d-137c8e7f5e64@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Apr 25, 2024 at 02:02:32PM +0200, Jakub Jelinek wrote: > I've tried the following patch, but unfortunately that lead to large > number of regressions: > +FAIL: g++.dg/cpp0x/initlist25.C -std=c++17 (test for excess errors) So the reduced testcase for this is template struct A { T a1; U a2; template constexpr A(V &&x, W &&y) : a1(x), a2(y) {} }; template struct B; namespace std { template struct initializer_list { int *_M_array; decltype (sizeof 0) _M_len; }; } template struct C { void foo (std::initializer_list>); }; template struct D; template , typename = B> struct E { E (const char *); ~E (); }; int main () { C, E> m; m.foo ({{"t", "t"}, {"y", "y"}}); } Without the patch I've just posted or even with the earlier version of the patch the _ZN1AIK1EIc1DIcE1BIcEES5_EC[12]IRA2_KcSB_Lb1EEEOT_OT0_ ctors were emitted, but with this patch they are unresolved externals. The reason is that the code actually uses (calls) the _ZN1AIK1EIc1DIcE1BIcEES5_EC1IRA2_KcSB_Lb1EEEOT_OT0_ __ct_comp constructor, that one has TREE_USED, while the _ZN1AIK1EIc1DIcE1BIcEES5_EC2IRA2_KcSB_Lb1EEEOT_OT0_ __ct_base constructor is not TREE_USED. But the c_parse_final_cleanups loop over FOR_EACH_VEC_SAFE_ELT (deferred_fns, i, decl) will ignore the TREE_USED __ct_comp because it is an alias and so has !DECL_SAVED_TREE: 5273 if (!DECL_SAVED_TREE (decl)) 5274 continue; With the following incremental patch the tests in make check-g++ (haven't tried the coroutine one) which failed with the earlier patch now pass. --- gcc/cp/decl2.cc.jj 2024-04-25 10:52:21.057535959 +0200 +++ gcc/cp/decl2.cc 2024-04-25 16:19:17.385547357 +0200 @@ -5271,7 +5271,19 @@ c_parse_final_cleanups (void) generate_tls_wrapper (decl); if (!DECL_SAVED_TREE (decl)) - continue; + { + cgraph_node *node; + tree tgt; + /* Even when maybe_clone_body created same body alias + has no DECL_SAVED_TREE, if its alias target does, + don't skip it. */ + if (!DECL_CLONED_FUNCTION (decl) + || !(node = cgraph_node::get (decl)) + || !node->cpp_implicit_alias + || !(tgt = node->get_alias_target_tree ()) + || !DECL_SAVED_TREE (tgt)) + continue; + } cgraph_node *node = cgraph_node::get_create (decl); @@ -5299,7 +5311,7 @@ c_parse_final_cleanups (void) node = node->get_alias_target (); node->call_for_symbol_thunks_and_aliases (clear_decl_external, - NULL, true); + NULL, true); /* If we mark !DECL_EXTERNAL one of the symbols in some comdat group, we need to mark all symbols in the same comdat group that way. */ @@ -5309,7 +5321,7 @@ c_parse_final_cleanups (void) next != node; next = dyn_cast (next->same_comdat_group)) next->call_for_symbol_thunks_and_aliases (clear_decl_external, - NULL, true); + NULL, true); } /* If we're going to need to write this function out, and Jakub