public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6964] c++, coroutines: Stabilize names of promoted slot vars [PR101118].
@ 2023-04-01  5:28 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2023-04-01  5:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fc4cde2e6aa4d6ebdf7f70b7b4359fb59a1915ae

commit r13-6964-gfc4cde2e6aa4d6ebdf7f70b7b4359fb59a1915ae
Author: Iain Sandoe <iain@sandoe.co.uk>
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 <iain@sandoe.co.uk>
    
            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.

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 a2189e43db8..b307c8ca8b6 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -2889,7 +2889,7 @@ flatten_await_stmt (var_nest_node *n, hash_set<tree> *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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-01  5:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01  5:28 [gcc r13-6964] c++, coroutines: Stabilize names of promoted slot vars [PR101118] Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).