https://gcc.gnu.org/g:432044b24a0460b31e332cf6ff92dc97ad1e8508
commit r15-4670-g432044b24a0460b31e332cf6ff92dc97ad1e8508 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Oct 25 14:05:37 2024 +0200 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 <ja...@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. Diff: --- gcc/lto/lto-common.cc | 6 +++ gcc/testsuite/gcc.dg/lto/pr117201_0.c | 26 ++++++++++++ gcc/testsuite/gcc.dg/lto/pr117288_0.c | 76 +++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc index 77607751db52..cc14cd7100f1 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 000000000000..e4bfce67b016 --- /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 000000000000..05179aa29cd9 --- /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); +}