From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id A72893858C27; Sun, 30 Apr 2023 08:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A72893858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682843251; bh=pVUrdk0gneJk1jXIbeASJFU6gKMtKJoYDT70v5CrD9Q=; h=From:To:Subject:Date:From; b=bZfsdv6b2dhnYrqYO4tRsAG36Hf8xCo6AofhjwcEI4OJ2gBaKOLzmh6oc1wOyNTVC qDqkQlsUSu71KktuRLEjdjCj48QaChcRcr4cWLlYooO2QrV3zPF4X8Z+41hFyH+/Xx nL6kvBsRBxwRnoM1kLLGIgxQbrXv2lE43TrYY3UA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9501] c++, coroutines: Stabilize names of promoted slot vars [PR101118]. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: db0985039fa58d5ef5d4ed10d2cbfd5b3ea6b3ee X-Git-Newrev: b7e75cdb218f25708b8b1aa3f4b138d88187491f Message-Id: <20230430082731.A72893858C27@sourceware.org> Date: Sun, 30 Apr 2023 08:27:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b7e75cdb218f25708b8b1aa3f4b138d88187491f commit r12-9501-gb7e75cdb218f25708b8b1aa3f4b138d88187491f Author: Iain Sandoe Date: Thu Mar 30 13:14:23 2023 +0530 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. (cherry picked from commit fc4cde2e6aa4d6ebdf7f70b7b4359fb59a1915ae) Diff: --- 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 71a22b5ad90..03ba3f6aa26 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2883,7 +2883,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", (unsigned) temps_used->elements ()); tree var = build_lang_decl (VAR_DECL, get_identifier (buf), var_type); DECL_ARTIFICIAL (var) = true; free (buf);