aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-05-21 10:12:40 +0200
committerRichard Biener <rguenther@suse.de>2024-05-21 12:00:10 +0200
commit85f7828679edc3ae7488594145756cd53787650e (patch)
treea5587c7c38a4fa0a1659e0dd12e5cf5196da9bd0
parent7f35863ebbf7ba63e2f075edfbec105de272578a (diff)
downloadgcc-85f7828679edc3ae7488594145756cd53787650e.zip
gcc-85f7828679edc3ae7488594145756cd53787650e.tar.gz
gcc-85f7828679edc3ae7488594145756cd53787650e.tar.bz2
tree-optimization/115137 - more ptr-vs-ptr compare fixes
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.
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr115137.c34
-rw-r--r--gcc/tree-ssa-structalias.cc1
2 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr115137.c b/gcc/testsuite/gcc.dg/torture/pr115137.c
new file mode 100644
index 0000000..9cd8ff9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115137.c
@@ -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);
+ }
+}
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 61fb361..0e9423a 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -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));
}