]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115137 - more ptr-vs-ptr compare fixes
authorRichard Biener <rguenther@suse.de>
Tue, 21 May 2024 08:12:40 +0000 (10:12 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 21 May 2024 10:00:10 +0000 (12:00 +0200)
The following fixes the omission of const-pool included in NONLOCAL.

PR tree-optimization/115137
* tree-ssa-structalias.cc (pt_solution_includes_const_pool): NONLOCAL
also includes constant pool entries.

* gcc.dg/torture/pr115137.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr115137.c [new file with mode: 0644]
gcc/tree-ssa-structalias.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr115137.c b/gcc/testsuite/gcc.dg/torture/pr115137.c
new file mode 100644 (file)
index 0000000..9cd8ff9
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+struct a {
+  int b;
+} c;
+
+int d;
+long e;
+
+static void f(char *g, char *h, struct a *l) {
+  char a[1024];
+  int j = 0;
+
+  if (d)
+    h = a;
+
+  for (; g < h; g++)
+    if (__builtin_iscntrl(*g))
+      ++j;
+
+  while (l->b < j)
+    ;
+}
+
+int main() {
+  static const struct {
+    char *input;
+  } k[] = {{"somepage.html"}, {""}};
+
+  for (unsigned int i = 0; i < 1; ++i) {
+    e = __builtin_strlen(k[i].input);
+    f(k[i].input, k[i].input + e, &c);
+  }
+}
index 61fb3610a1725407c755fd15ddd81b96d57f5ec8..0e9423a78ecb619d3b6cc22b627756217c1a3ded 100644 (file)
@@ -7087,6 +7087,7 @@ bool
 pt_solution_includes_const_pool (struct pt_solution *pt)
 {
   return (pt->const_pool
+         || pt->nonlocal
          || (pt->escaped && (!cfun || cfun->gimple_df->escaped.const_pool))
          || (pt->ipa_escaped && ipa_escaped_pt.const_pool));
 }