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.129.124]) by sourceware.org (Postfix) with ESMTPS id DA8D03858D1E for ; Wed, 29 Mar 2023 19:23:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA8D03858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680117817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=venvvoyWcZ/axorBZqgopCmzU7t/I2rumcl9MHSugiw=; b=RgQWDIEt8ORT0vcmjTXVOBTJsz2Ejxsgx461sJBKrSr+tLgKjl6AFrqNwy4PUkWvasPi/R 783jn3wgLqGnW4yg+FXqF6e2LTn5KmqL64/1Y4GAMuFiJ+P4FtNZDo84gESGxWQPyVmzZA 3MblDHrX6Khxwe5RqvotVjGthWEliwg= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-mdRtKRHrNXqKWEq_6ABfgQ-1; Wed, 29 Mar 2023 15:23:36 -0400 X-MC-Unique: mdRtKRHrNXqKWEq_6ABfgQ-1 Received: by mail-qt1-f198.google.com with SMTP id h6-20020ac85846000000b003e3c23d562aso10917955qth.1 for ; Wed, 29 Mar 2023 12:23:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680117815; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=venvvoyWcZ/axorBZqgopCmzU7t/I2rumcl9MHSugiw=; b=GYT4NhC5EvFR8aW+nbBv4QJ4iZMVxWiV29+pVjMUd+/+iY8Pc2iHgB2wERgfHycSst hah8vWHFWSaKGC0t3Rr380jY/qvYyj4oTSuh1Fa2BJYXhvB9d6E/Dav2Zi2AvrJH0YZl VVPKBJB1qoG3J42WCysnZ3oodG2lf9WikTG8xzlM3VrXEzLjpFIXh+HUdLFb3Xh95xV/ vfmM0aMCJZ1WzDPnpYUN92WKC1m0/STMAMQKLIaZgrmyfDoRbt/Go/is1xJaDDRHqk3P 0lx2OYLCyKMtLDp8Fe/9JnHAmB3+oqZ31k8AjTzxjEk6RBUkYKtsPN9uNaI4wVfgrebx jVWA== X-Gm-Message-State: AAQBX9f7Q4TNwCD5g9SqUU7vOyQnRDEfq56r6ocRPKN/BsDJT1Of0BBB DItRVXuP+EHqIhuTH0gTLGcJu/CCzRUPYILIsHpE/+MUoocRMI5pqhslQj4RLYiSP3eKHXXE3nw egMaFomOenUlWEs565ScU1UrsAw== X-Received: by 2002:ad4:5aef:0:b0:56e:a7d9:b132 with SMTP id c15-20020ad45aef000000b0056ea7d9b132mr6186222qvh.22.1680117815561; Wed, 29 Mar 2023 12:23:35 -0700 (PDT) X-Google-Smtp-Source: AKy350ZHeK0oDh+CZrfgHROOCU3cHiLoVUjIKcujcehdkte/gr94qtVRw9X8tNJbGbfV5GHFb8jphw== X-Received: by 2002:ad4:5aef:0:b0:56e:a7d9:b132 with SMTP id c15-20020ad45aef000000b0056ea7d9b132mr6186174qvh.22.1680117815192; Wed, 29 Mar 2023 12:23:35 -0700 (PDT) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id c18-20020a0cd612000000b005dd8b9345f0sm4830197qvj.136.2023.03.29.12.23.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 12:23:34 -0700 (PDT) Message-ID: <5ebaf601-dca1-292b-de37-b748ab3f6e51@redhat.com> Date: Wed, 29 Mar 2023 15:23:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] c++,coroutines: Stabilize names of promoted slot vars [PR101118]. To: iain@sandoe.co.uk, gcc-patches@gcc.gnu.org References: <20230326165447.43628-1-iain@sandoe.co.uk> From: Jason Merrill In-Reply-To: <20230326165447.43628-1-iain@sandoe.co.uk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 3/26/23 12:54, Iain Sandoe wrote: > Tested on x86_64-darwin21, x86-64-linux-gnu > OK for trunk? > Iain > > 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 a counter instead of the DECL_UID which makes a name > that is stable between TUs for each frame layout (one per coroutine func). > > Signed-off-by: Iain Sandoe > > PR c++/101118 > > gcc/cp/ChangeLog: > > * coroutines.cc: Add counter for promoted slot vars. > (flatten_await_stmt): Use slot vars counter instead of DECL_UID > to generate the frame entry name for promoted target expression > slot variables. > (morph_fn_to_coro): Reset the slot vars counter at the start of > each coroutine function. > --- > gcc/cp/coroutines.cc | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc > index a2189e43db8..359a5bf46ff 100644 > --- a/gcc/cp/coroutines.cc > +++ b/gcc/cp/coroutines.cc > @@ -2726,6 +2726,11 @@ struct var_nest_node > var_nest_node *else_cl; > }; > > +/* 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 = 0; How about using temps_used->elements() for the index instead of a separate static counter? > /* This is called for single statements from the co-await statement walker. > It checks to see if the statement contains any initializers for awaitables > and if any of these capture items by reference. */ > @@ -2889,7 +2894,7 @@ flatten_await_stmt (var_nest_node *n, hash_set *promoted, > tree init = t; > temps_used->add (init); > tree var_type = TREE_TYPE (init); > - char *buf = xasprintf ("D.%d", DECL_UID (TREE_OPERAND (init, 0))); > + char *buf = xasprintf ("T%03u", tmpno++); > tree var = build_lang_decl (VAR_DECL, get_identifier (buf), var_type); > DECL_ARTIFICIAL (var) = true; > free (buf); > @@ -4374,6 +4379,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) > { > gcc_checking_assert (orig && TREE_CODE (orig) == FUNCTION_DECL); > > + tmpno = 0; > *resumer = error_mark_node; > *destroyer = error_mark_node; > if (!coro_function_valid_p (orig))