The ptr-vs-ptr compare folding using points-to info was missing a
check for const_pool being included in the escaped solution. The
following fixes that, fixing the observed execute FAIL of
experimental/functional/searchers.cc
* tree-ssa-alias.h (pt_solution_includes_const_pool): Declare.
* tree-ssa-alias.cc (ptrs_compare_unequal): Use
pt_solution_includes_const_pool.
* tree-ssa-structalias.cc (pt_solution_includes_const_pool): New.
* gcc.dg/torture/
20240517-1.c: New testcase.
--- /dev/null
+/* { dg-do run } */
+/* { dg-additional-options "-fmerge-all-constants" } */
+
+char *p;
+
+char * __attribute__((noipa))
+foo () { return p+1; }
+
+volatile int z;
+
+int main()
+{
+ /* ESCAPED = CONST_POOL */
+ p = "Hello";
+ /* PT = ESCAPED */
+ char *x = foo ();
+ char *y;
+ /* y PT = CONST_POOL */
+ if (z)
+ y = "Baz";
+ else
+ y = "Hello" + 1;
+ if (y != x)
+ __builtin_abort ();
+ return 0;
+}
|| pi2->pt.vars_contains_interposable)
return false;
if ((!pi1->pt.null || !pi2->pt.null)
- && (!pi1->pt.const_pool || !pi2->pt.const_pool))
+ && (!pt_solution_includes_const_pool (&pi1->pt)
+ || !pt_solution_includes_const_pool (&pi2->pt)))
return !pt_solutions_intersect (&pi1->pt, &pi2->pt);
}
}
extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *);
extern bool pt_solution_includes_global (struct pt_solution *, bool);
extern bool pt_solution_includes (struct pt_solution *, const_tree);
+extern bool pt_solution_includes_const_pool (struct pt_solution *);
extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
extern void pt_solution_reset (struct pt_solution *);
extern void pt_solution_set (struct pt_solution *, bitmap, bool);
return res;
}
+/* Return true if the points-to solution *PT contains a reference to a
+ constant pool entry. */
+
+bool
+pt_solution_includes_const_pool (struct pt_solution *pt)
+{
+ return (pt->const_pool
+ || (pt->escaped && (!cfun || cfun->gimple_df->escaped.const_pool))
+ || (pt->ipa_escaped && ipa_escaped_pt.const_pool));
+}
+
/* Return true if both points-to solutions PT1 and PT2 have a non-empty
intersection. */