aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-05-23 13:33:15 +0200
committerRichard Biener <rguenther@suse.de>2024-05-23 14:38:49 +0200
commitf0a02467bbc35a478eb82f5a8a7e8870827b51fc (patch)
tree2bd554b0bd652af469d52dd8a0421ddb1b6acc0a /gcc
parent61f5b3c59ed20438d7d9918d7a83d29a21097d4e (diff)
downloadgcc-f0a02467bbc35a478eb82f5a8a7e8870827b51fc.zip
gcc-f0a02467bbc35a478eb82f5a8a7e8870827b51fc.tar.gz
gcc-f0a02467bbc35a478eb82f5a8a7e8870827b51fc.tar.bz2
tree-optimization/115199 - fix PTA constraint processing for &ANYTHING LHS
When processing a &ANYTHING = X constraint we treat it as *ANYTHING = X during constraint processing but then end up recording it as &ANYTHING = X anyway, breaking constraint graph building. This is because we only update the local copy of the LHS and not the constraint itself. PR tree-optimization/115199 * tree-ssa-structalias.cc (process_constraint): Also record &ANYTHING = X as *ANYTING = X in the end. * gcc.dg/torture/pr115199.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr115199.c24
-rw-r--r--gcc/tree-ssa-structalias.cc2
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr115199.c b/gcc/testsuite/gcc.dg/torture/pr115199.c
new file mode 100644
index 0000000..981a733
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115199.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+struct b {
+ char *volatile c;
+};
+struct b * __attribute__((noipa))
+d()
+{
+ char *e;
+ struct b *b = __builtin_malloc(sizeof(b));
+ void *f = __builtin_malloc(1);
+
+ e = __builtin_memcpy(f, "z", 1);
+ b->c = e;
+ return b;
+}
+
+int main()
+{
+ struct b b = *d();
+ if (b.c[0] != 'z')
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 0e9423a..a39b36c 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -3104,7 +3104,7 @@ process_constraint (constraint_t t)
it here by turning it into *ANYTHING. */
if (lhs.type == ADDRESSOF
&& lhs.var == anything_id)
- lhs.type = DEREF;
+ t->lhs.type = lhs.type = DEREF;
/* ADDRESSOF on the lhs is invalid. */
gcc_assert (lhs.type != ADDRESSOF);