[gcc/devel/ranger] middle-end: Avoid using DECL_UID in ASM_FORMAT_PRIVATE_NAME [PR94223]
Aldy Hernandez
aldyh@gcc.gnu.org
Wed Jun 17 19:55:19 GMT 2020
https://gcc.gnu.org/g:158cccea0d097d9f181bf4e35fdeb97865c960f7
commit 158cccea0d097d9f181bf4e35fdeb97865c960f7
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Mar 25 09:18:33 2020 +0100
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.
Diff:
---
gcc/ChangeLog | 4 ++++
gcc/langhooks.c | 5 +++--
gcc/lto/ChangeLog | 6 ++++++
gcc/lto/lto-lang.c | 3 ++-
gcc/testsuite/ChangeLog | 3 +++
gcc/testsuite/g++.dg/opt/pr94223.C | 5 +++++
6 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4a0e473afd7..cde4653c030 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 640bd012d1c..5e3216da631 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -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);
}
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 619a42d5142..4171a3dc4ae 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -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
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index a5638e7a2a0..a3e841850ed 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -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);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2a39af6feab..048f830409e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/opt/pr94223.C b/gcc/testsuite/g++.dg/opt/pr94223.C
new file mode 100644
index 00000000000..0de012de504
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr94223.C
@@ -0,0 +1,5 @@
+// PR c++/94223
+// { dg-do compile }
+// { dg-options "-O0 -std=c++2a -fcompare-debug" }
+
+#include "../cpp1z/init-statement6.C"
More information about the Gcc-cvs
mailing list