aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain
diff options
context:
space:
mode:
authorNick Hainke <vincent@systemli.org>2023-05-03 16:46:52 +0200
committerChristian Marangi <ansuelsmth@gmail.com>2023-05-05 15:46:38 +0200
commita6d689632c5326e4869937c0ff5f9c72f6190729 (patch)
tree2079482dc4bef4e6f3d2534192a5c56b5976d996 /toolchain
parent29128b0bd43532404d965d22338554fce624db6a (diff)
downloadupstream-a6d689632c5326e4869937c0ff5f9c72f6190729.tar.gz
upstream-a6d689632c5326e4869937c0ff5f9c72f6190729.tar.bz2
upstream-a6d689632c5326e4869937c0ff5f9c72f6190729.zip
toolchain: gcc: backport patch for gcc 13 fixing access path analysis
While improving access path analysis a typo happened. Now it can happen that gcc misscompiles. The patch is fixing the issue. However, also other gcc versions 10.2+ are affected. They also should be bumped or the fix should be backported. For more bug information have a look at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585 Signed-off-by: Nick Hainke <vincent@systemli.org>
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch b/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch
new file mode 100644
index 0000000000..7f73be4325
--- /dev/null
+++ b/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch
@@ -0,0 +1,69 @@
+From bb406a6aea336966681927a27f54ee89c4fd4ea1 Mon Sep 17 00:00:00 2001
+From: Richard Biener <rguenther@suse.de>
+Date: Mon, 24 Apr 2023 13:31:07 +0200
+Subject: [PATCH] rtl-optimization/109585 - alias analysis typo
+
+When r10-514-gc6b84edb6110dd2b4fb improved access path analysis
+it introduced a typo that triggers when there's an access to a
+trailing array in the first access path leading to false
+disambiguation.
+
+ PR rtl-optimization/109585
+ * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
+
+ * gcc.dg/torture/pr109585.c: New testcase.
+
+(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)
+---
+ gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++
+ gcc/tree-ssa-alias.cc | 2 +-
+ 2 files changed, 34 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c
+
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/torture/pr109585.c
+@@ -0,0 +1,33 @@
++/* { dg-do run } */
++
++#include <stdlib.h>
++
++struct P {
++ long v;
++ struct P *n;
++};
++
++struct F {
++ long x;
++ struct P fam[];
++};
++
++int __attribute__((noipa))
++f(struct F *f, int i)
++{
++ struct P *p = f->fam;
++ asm("" : "+r"(f): "r"(p));
++ p->v = 0;
++ p->n = 0;
++ return f->fam->n != 0;
++}
++
++int
++main()
++{
++ struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P));
++ m->fam[0].n = &m->fam[1];
++ if (f (m, 0))
++ abort ();
++ return 0;
++}
+--- a/gcc/tree-ssa-alias.cc
++++ b/gcc/tree-ssa-alias.cc
+@@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1,
+ /* If we didn't find a common base, try the other way around. */
+ if (cmp_outer <= 0
+ || (end_struct_ref1
+- && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0))
++ && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0))
+ {
+ int res = aliasing_component_refs_walk (ref2, type2, base2,
+ offset2, max_size2,