From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 23D903858CDA for ; Thu, 30 Mar 2023 07:53:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23D903858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 59833 invoked from network); 30 Mar 2023 07:53:10 -0000 X-APM-Out-ID: 16801627855976 X-APM-Authkey: 257869/1(257869/1) 3 Received: from unknown (HELO smtpclient.apple) (103.2.133.137) by smtp001.apm-internet.net with SMTP; 30 Mar 2023 07:53:10 -0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: [PATCH] c++,coroutines: Stabilize names of promoted slot vars [PR101118]. From: Iain Sandoe In-Reply-To: <5ebaf601-dca1-292b-de37-b748ab3f6e51@redhat.com> Date: Thu, 30 Mar 2023 13:23:03 +0530 Cc: GCC Patches Content-Transfer-Encoding: quoted-printable Message-Id: <86FF61EC-F584-4249-A5A6-2EAE883FC4D2@sandoe.co.uk> References: <20230326165447.43628-1-iain@sandoe.co.uk> <5ebaf601-dca1-292b-de37-b748ab3f6e51@redhat.com> To: Jason Merrill X-Mailer: Apple Mail (2.3696.120.41.1.2) X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_COUK,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_LOW,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: Hi Jason, > On 30 Mar 2023, at 00:53, Jason Merrill wrote: >=20 > On 3/26/23 12:54, Iain Sandoe wrote: >> Tested on x86_64-darwin21, x86-64-linux-gnu >> +/* This is used to make a stable, but unique-per-function, sequence = number for >> + each TARGET_EXPR slot variable that we 'promote' to a frame = entry. It needs >> + to be stable because the frame type is visible to LTO ODR = checking. */ >> +static unsigned tmpno =3D 0; >=20 > How about using temps_used->elements() for the index instead of a = separate static counter? That=E2=80=99s a good idea (the only slightly weird effect is that the = count does not start at 0,=20 because we=E2=80=99ve added one or more entries by the time we get to = produce a name, but that does not affect functionality). re-tested on x86_64-darwin21, as below, OK for trunk? thanks Iain =3D=3D=3D [PATCH] c++,coroutines: Stabilize names of promoted slot vars = [PR101118]. When we need to 'promote' a value (i.e. store it in the coroutine frame) = it is given a frame entry name. This was based on the DECL_UID for slot = vars. However, when LTO is used, the names from multiple TUs become visible at = the same time, and the DECL_UIDs usually differ between units. This leads = to a "ODR mismatch" warning for the frame type. The fix here is to use the current promoted temporaries count to produce the name, this is stable between TUs and computed per coroutine. Signed-off-by: Iain Sandoe PR c++/101118 gcc/cp/ChangeLog: * coroutines.cc (flatten_await_stmt): Use the current count of promoted temporaries to build a unique name for the frame = entries. --- gcc/cp/coroutines.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index a2189e43db8..9f546db7437 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2889,7 +2889,7 @@ flatten_await_stmt (var_nest_node *n, = hash_set *promoted, tree init =3D t; temps_used->add (init); tree var_type =3D TREE_TYPE (init); - char *buf =3D xasprintf ("D.%d", DECL_UID (TREE_OPERAND (init, = 0))); + char *buf =3D xasprintf ("T%03u", temps_used->elements()); tree var =3D build_lang_decl (VAR_DECL, get_identifier (buf), = var_type); DECL_ARTIFICIAL (var) =3D true; free (buf); =E2=80=94=20