[PATCH] lto/108445 - avoid LTO decl wrapping being confused by tree sharing
Richard Biener
rguenther@suse.de
Wed Jan 18 13:57:06 GMT 2023
r13-4743 exposed more tree sharing which runs into a latent issue
with LTO decl wrapping during streaming. The following adds a
testcase triggering the issue.
Pushed.
PR lto/108445
* gcc.dg/lto/pr108445_0.c: New testcase.
* gcc.dg/lto/pr108445_1.c: Likewise.
---
gcc/testsuite/gcc.dg/lto/pr108445_0.c | 4 ++++
gcc/testsuite/gcc.dg/lto/pr108445_1.c | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/lto/pr108445_0.c
create mode 100644 gcc/testsuite/gcc.dg/lto/pr108445_1.c
diff --git a/gcc/testsuite/gcc.dg/lto/pr108445_0.c b/gcc/testsuite/gcc.dg/lto/pr108445_0.c
new file mode 100644
index 00000000000..06dac691e84
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr108445_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { "-g -O2 -flto" } } */
+
+int gArray[16];
diff --git a/gcc/testsuite/gcc.dg/lto/pr108445_1.c b/gcc/testsuite/gcc.dg/lto/pr108445_1.c
new file mode 100644
index 00000000000..50db9feb8a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr108445_1.c
@@ -0,0 +1,19 @@
+extern int gArray[];
+
+int foo(int *a)
+{
+ int *p = a;
+
+ return *p;
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc & 1)
+ gArray[argc - 1] = 1;
+
+ if (argc > 1)
+ return foo(gArray);
+
+ return 0;
+}
--
2.35.3
More information about the Gcc-patches
mailing list