On Thu, Apr 28, 2022 at 11:22:45PM +0100, Iain Sandoe wrote:
> how about the following, which uniques the names by bind scope, scope nest 
> and then
> sequence within that?

That LGTM.

> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -3913,6 +3913,7 @@ register_local_var_uses (tree *stmt, int *do_subtree, 
> void *d)
>    if (TREE_CODE (*stmt) == BIND_EXPR)
>      {
>        tree lvar;
> +      unsigned serial = 0;
>        for (lvar = BIND_EXPR_VARS (*stmt); lvar != NULL;
>            lvar = DECL_CHAIN (lvar))
>         {
> @@ -3974,16 +3975,14 @@ register_local_var_uses (tree *stmt, int *do_subtree, 
> void *d)
>             buf = xasprintf ("%s_%u_%u", IDENTIFIER_POINTER (lvname),
>                              lvd->nest_depth, lvd->bind_indx);
>           else
> -           buf = xasprintf ("_D%u_%u_%u", DECL_UID (lvar), lvd->nest_depth,
> -                            lvd->bind_indx);
> +           buf = xasprintf ("_D%u_%u_%u", lvd->nest_depth, lvd->bind_indx,
> +                            serial++);
> +
>           /* TODO: Figure out if we should build a local type that has any
>              excess alignment or size from the original decl.  */
> -         if (buf)
> -           {
> -             local_var.field_id = coro_make_frame_entry (lvd->field_list, 
> buf,
> -                                                         lvtype, lvd->loc);
> -             free (buf);
> -           }
> +         local_var.field_id = coro_make_frame_entry (lvd->field_list, buf,
> +                                                     lvtype, lvd->loc);
> +         free (buf);
>           /* We don't walk any of the local var sub-trees, they won't contain
>              any bind exprs.  */
>         }
> 
> 
> 

        Jakub

Reply via email to