On Wed, Aug 07, 2024 at 11:10:37AM +0200, Jakub Jelinek wrote:
> > In any case how about the simpler
> > 
> >         if (!DECL_NAME (object) || DECL_NAMELESS (object))
> >           DECL_NAME (object) = create_tmp_var_name ("C");
> > 
> > ?
> 
> This is what I had in my first version, but I was worried too many things
> would be DECL_NAMELESS during gimplification.  I think I'll do another
> bootstrap/regtest with statistics gathering to see what is worth.

As {x86_64,i686,powerpc64le}-linux bootstraps/regtests never triggered
that, I've used the above in what I've committed:

2024-08-07  Jakub Jelinek  <ja...@redhat.com>

        PR c++/116219
        * gimple-expr.cc (remove_suffix): Formatting fixes.
        (create_tmp_var_name): Don't call clean_symbol_name.
        * gimplify.cc (gimplify_init_constructor): When promoting automatic
        DECL_NAMELESS vars to static, don't preserve their DECL_NAME.

--- gcc/gimple-expr.cc.jj       2024-01-03 11:51:28.280776310 +0100
+++ gcc/gimple-expr.cc  2024-08-06 14:43:42.328673383 +0200
@@ -406,14 +406,12 @@ remove_suffix (char *name, int len)
 {
   int i;
 
-  for (i = 2;  i < 7 && len > i;  i++)
-    {
-      if (name[len - i] == '.')
-       {
-         name[len - i] = '\0';
-         break;
-       }
-    }
+  for (i = 2; i < 7 && len > i; i++)
+    if (name[len - i] == '.')
+      {
+       name[len - i] = '\0';
+       break;
+      }
 }
 
 /* Create a new temporary name with PREFIX.  Return an identifier.  */
@@ -430,8 +428,6 @@ create_tmp_var_name (const char *prefix)
       char *preftmp = ASTRDUP (prefix);
 
       remove_suffix (preftmp, strlen (preftmp));
-      clean_symbol_name (preftmp);
-
       prefix = preftmp;
     }
 
--- gcc/gimplify.cc.jj  2024-08-05 13:04:53.903116091 +0200
+++ gcc/gimplify.cc     2024-08-07 20:13:05.443907561 +0200
@@ -5599,7 +5599,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq 
*pre_p, gimple_seq *post_p,
 
            DECL_INITIAL (object) = ctor;
            TREE_STATIC (object) = 1;
-           if (!DECL_NAME (object))
+           if (!DECL_NAME (object) || DECL_NAMELESS (object))
              DECL_NAME (object) = create_tmp_var_name ("C");
            walk_tree (&DECL_INITIAL (object), force_labels_r, NULL, NULL);
 


        Jakub

Reply via email to