aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-10-25 14:05:37 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2024-10-25 14:05:37 +0200
commit432044b24a0460b31e332cf6ff92dc97ad1e8508 (patch)
treec6d0590e3d3a6473475eb26fff6060ab3ac9a8a7 /gcc
parent35c3aac80e7a18c32436259143cba0f47bd0cb5a (diff)
downloadgcc-432044b24a0460b31e332cf6ff92dc97ad1e8508.zip
gcc-432044b24a0460b31e332cf6ff92dc97ad1e8508.tar.gz
gcc-432044b24a0460b31e332cf6ff92dc97ad1e8508.tar.bz2
lto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201]
I've missed I need to add RAW_DATA_CST support in compare_tree_sccs_1, because without that it considers all RAW_DATA_CSTs to be equivalent, regardless of their length or content. 2024-10-24 Jakub Jelinek <jakub@redhat.com> PR lto/117201 PR lto/117288 * lto-common.cc (compare_tree_sccs_1): Handle RAW_DATA_CST. * gcc.dg/lto/pr117201_0.c: New test. * gcc.dg/lto/pr117288_0.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/lto/lto-common.cc6
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr117201_0.c26
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr117288_0.c76
3 files changed, 108 insertions, 0 deletions
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 7760775..cc14cd7 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -1336,6 +1336,12 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
TREE_STRING_LENGTH (t1)) != 0)
return false;
+ if (code == RAW_DATA_CST)
+ if (RAW_DATA_LENGTH (t1) != RAW_DATA_LENGTH (t2)
+ || memcmp (RAW_DATA_POINTER (t1), RAW_DATA_POINTER (t2),
+ RAW_DATA_LENGTH (t1)) != 0)
+ return false;
+
if (code == OMP_CLAUSE)
{
compare_values (OMP_CLAUSE_CODE);
diff --git a/gcc/testsuite/gcc.dg/lto/pr117201_0.c b/gcc/testsuite/gcc.dg/lto/pr117201_0.c
new file mode 100644
index 0000000..e4bfce6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr117201_0.c
@@ -0,0 +1,26 @@
+/* PR lto/117201 */
+/* { dg-lto-do run } */
+/* { dg-lto-options { "-O0 -flto" } } */
+
+unsigned char a = 193;
+unsigned char *b = &a;
+
+void
+foo (void)
+{
+ unsigned char c[] = { 0, 2, 1, 1, 2, 1, 2, 2, 6, 2, 1, 1, 1, 1, 2, 2, 0,
+ 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2,
+ 1, 1, 2, 1, 2, 2, 1, 1, 2, 4, 8, 8, 3, 3, 1, 1, 5,
+ 4, 1, 1, 1, 0, 5, 5, 9, 4, 8, 8, 7, 0, 1, 1 };
+}
+
+int
+main ()
+{
+ unsigned char c[] = { 193, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 5, 2, 3, 1, 0,
+ 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 4,
+ 2, 2, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+ 1, 1, 0, 5, 3, 3, 1, 0, 1, 0, 0, 1, 0, 1, 0 };
+ if (b[0] != c[0])
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr117288_0.c b/gcc/testsuite/gcc.dg/lto/pr117288_0.c
new file mode 100644
index 0000000..05179aa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr117288_0.c
@@ -0,0 +1,76 @@
+/* PR lto/117288 */
+/* { dg-lto-do link } */
+/* { dg-lto-options { "-O0 -flto" } } */
+
+__attribute__((noipa)) static void
+foo (const void *x)
+{
+ (void) x;
+}
+
+static void
+bar (void)
+{
+ unsigned char a[81] = {
+ 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0xfa, 0x01, 0x00, 0x01,
+ 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0xee, 0xfe, 0xfd, 0xc0, 0xca, 0xb5, 0x6f, 0x3d,
+ 0x23, 0xcc, 0x53, 0x9a, 0x67, 0x17, 0x70, 0xd3,
+ 0xfb, 0x23, 0x16, 0x9e, 0x4e, 0xd6, 0x7e, 0x29,
+ 0xab, 0xfa, 0x4c, 0xa5, 0x84, 0x95, 0xc3, 0xdb,
+ 0x21, 0x9a, 0x52, 0x00, 0x00, 0x00, 0x36, 0x13,
+ 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2c, 0xc0,
+ 0x2b, 0xc0, 0x30, 0xc0, 0x2f, 0x00, 0x9f, 0x00,
+ 0x9e,
+ };
+ foo (&a);
+}
+
+static void
+baz (void)
+{
+ const struct S
+ {
+ unsigned char a[32];
+ int b;
+ unsigned char c[32];
+ int d;
+ unsigned char e[32];
+ int f;
+ unsigned char g[80];
+ int h;
+ unsigned char i[80];
+ int j;
+ } s = {
+ { 0x00, }, 16,
+ { 0x4f, }, 16,
+ { 0x00 }, 0,
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, 80,
+ { 0xe9, }, 80,
+ };
+
+ foo (s.g);
+}
+
+__attribute__((noipa)) static void
+qux (const void (*x) (void))
+{
+ (void) x;
+}
+
+int
+main ()
+{
+ qux (&baz);
+ qux (&bar);
+}