]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto/108445 - avoid LTO decl wrapping being confused by tree sharing
authorRichard Biener <rguenther@suse.de>
Wed, 18 Jan 2023 13:54:33 +0000 (14:54 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 18 Jan 2023 13:57:24 +0000 (14:57 +0100)
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.

gcc/testsuite/gcc.dg/lto/pr108445_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr108445_1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/lto/pr108445_0.c b/gcc/testsuite/gcc.dg/lto/pr108445_0.c
new file mode 100644 (file)
index 0000000..06dac69
--- /dev/null
@@ -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 (file)
index 0000000..50db9fe
--- /dev/null
@@ -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;
+}