On Wed, 25 Mar 2020, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, we don't guarantee DECL_UID to be the same between > corresponding decls in -g and -g0 builds, -g can create more decls and all > that is guaranteed is that the DECL_UIDs of the corresponding decls compare > the same. > The following testcase gets a -fcompare-debug failure because these > functions use DECL_UID as the number in ASM_FORMAT_PRIVATE_NAME. > > The patch fixes it by using just a sequential number there instead. > I don't think this can be called during PCH writing, this only happens for > non-public decls and the C/C++ FEs shouldn't mangling those at that point > (furthermore C++ FE uses a different set_decl_assembler_name hook and this > one is something only the gimplifier calls on C.NNNN temporaries. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK. Thanks, Richard. > 2020-03-25 Jakub Jelinek <ja...@redhat.com> > > PR c++/94223 > * langhooks.c (lhd_set_decl_assembler_name): Use a static ulong > counter instead of DECL_UID. > > * lto-lang.c (lto_set_decl_assembler_name): Use a static ulong > counter instead of DECL_UID. > > * g++.dg/opt/pr94223.C: New test. > > --- gcc/langhooks.c.jj 2020-01-12 11:54:36.670409531 +0100 > +++ gcc/langhooks.c 2020-03-24 16:05:26.728284808 +0100 > @@ -160,16 +160,17 @@ lhd_set_decl_assembler_name (tree decl) > > Can't use just the variable's own name for a variable whose scope > is less than the whole compilation. Concatenate a distinguishing > - number - we use the DECL_UID. */ > + number. */ > > if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl)) > id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); > else > { > const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); > + static unsigned long num; > char *label; > > - ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); > + ASM_FORMAT_PRIVATE_NAME (label, name, num++); > id = get_identifier (label); > } > > --- gcc/lto/lto-lang.c.jj 2020-01-12 11:54:36.678409411 +0100 > +++ gcc/lto/lto-lang.c 2020-03-24 13:55:10.463826320 +0100 > @@ -1179,8 +1179,9 @@ lto_set_decl_assembler_name (tree decl) > { > const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); > char *label; > + static unsigned long num; > > - ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); > + ASM_FORMAT_PRIVATE_NAME (label, name, num++); > id = get_identifier (label); > } > > --- gcc/testsuite/g++.dg/opt/pr94223.C.jj 2020-03-24 16:03:42.069863475 > +0100 > +++ gcc/testsuite/g++.dg/opt/pr94223.C 2020-03-24 16:04:53.327788620 > +0100 > @@ -0,0 +1,5 @@ > +// PR c++/94223 > +// { dg-do compile } > +// { dg-options "-O0 -std=c++2a -fcompare-debug" } > + > +#include "../cpp1z/init-statement6.C" > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)