aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-01-18 14:54:33 +0100
committerRichard Biener <rguenther@suse.de>2023-01-18 14:57:24 +0100
commitd4abe5c456a3023f61c3e053255b7dd72ca0d7ec (patch)
tree469f11009a68d7fde17b31a70790deb9f7ac28eb
parentddbe758b1742699481886fffa2afe17c28ec5315 (diff)
downloadgcc-d4abe5c456a3023f61c3e053255b7dd72ca0d7ec.zip
gcc-d4abe5c456a3023f61c3e053255b7dd72ca0d7ec.tar.gz
gcc-d4abe5c456a3023f61c3e053255b7dd72ca0d7ec.tar.bz2
lto/108445 - avoid LTO decl wrapping being confused by tree sharing
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. PR lto/108445 * gcc.dg/lto/pr108445_0.c: New testcase. * gcc.dg/lto/pr108445_1.c: Likewise.
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr108445_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr108445_1.c19
2 files changed, 23 insertions, 0 deletions
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 0000000..06dac69
--- /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 0000000..50db9fe
--- /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;
+}