mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-28 16:01:00 +08:00
middle-end: Avoid using DECL_UID in ASM_FORMAT_PRIVATE_NAME [PR94223]
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. 2020-03-25 Jakub Jelinek <jakub@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.
This commit is contained in:
parent
f1154b4d3c
commit
158cccea0d
@ -1,5 +1,9 @@
|
||||
2020-03-25 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/94223
|
||||
* langhooks.c (lhd_set_decl_assembler_name): Use a static ulong
|
||||
counter instead of DECL_UID.
|
||||
|
||||
PR tree-optimization/94300
|
||||
* tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): If pd.offset
|
||||
is positive, make sure that off + size isn't larger than needed_len.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2020-03-25 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/94223
|
||||
* lto-lang.c (lto_set_decl_assembler_name): Use a static ulong
|
||||
counter instead of DECL_UID.
|
||||
|
||||
2020-03-24 Tobias Burnus <tobias@codesourcery.com>
|
||||
|
||||
PR libgomp/81689
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
2020-03-25 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/94223
|
||||
* g++.dg/opt/pr94223.C: New test.
|
||||
|
||||
PR tree-optimization/94300
|
||||
* gcc.target/i386/avx512f-pr94300.c: New test.
|
||||
|
||||
|
5
gcc/testsuite/g++.dg/opt/pr94223.C
Normal file
5
gcc/testsuite/g++.dg/opt/pr94223.C
Normal file
@ -0,0 +1,5 @@
|
||||
// PR c++/94223
|
||||
// { dg-do compile }
|
||||
// { dg-options "-O0 -std=c++2a -fcompare-debug" }
|
||||
|
||||
#include "../cpp1z/init-statement6.C"
|
Loading…
x
Reference in New Issue
Block a user