The following fixes
int
f5 (S *__restrict x, S *__restrict y)
{
x->p[0] = 5;
y->p[0] = 0;
// { dg-final { scan-tree-dump-times "return 5" 1 "optimized" { xfail
*-*-* } } }
return x->p[0];
}
which requires building representatives for restrict qualified pointers
(as opposed to references or decl-by-references). The fear here was
that as we can access that representative with out-of-bound objects
(we eventually point to an array) we'd miscompute points-to sets.
I verified we do the obvious thing here, namely glob those accesses
to the first/last subfield of the representative (that code was added
to compensate for pointer arithmetic going ouf-of-bounds).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2015-09-23 Richard Biener <[email protected]>
* tree-ssa-structalias.c (intra_create_variable_infos): Build
representatives for all restrict qualified pointer destinations.
* g++.dg/tree-ssa/restrict2.C: Un-XFAIL testcase.
Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c (revision 228014)
--- gcc/tree-ssa-structalias.c (working copy)
*************** intra_create_variable_infos (struct func
*** 5854,5865 ****
{
varinfo_t p = get_vi_for_tree (t);
! /* For restrict qualified pointers to objects passed by
! reference build a real representative for the pointed-to object.
! Treat restrict qualified references the same. */
! if (TYPE_RESTRICT (TREE_TYPE (t))
! && ((DECL_BY_REFERENCE (t) && POINTER_TYPE_P (TREE_TYPE (t)))
! || TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
&& !type_contains_placeholder_p (TREE_TYPE (TREE_TYPE (t))))
{
struct constraint_expr lhsc, rhsc;
--- 5854,5865 ----
{
varinfo_t p = get_vi_for_tree (t);
! /* For restrict qualified pointers build a representative for
! the pointed-to object. Note that this ends up handling
! out-of-bound references conservatively by aggregating them
! in the first/last subfield of the object. */
! if (POINTER_TYPE_P (TREE_TYPE (t))
! && TYPE_RESTRICT (TREE_TYPE (t))
&& !type_contains_placeholder_p (TREE_TYPE (TREE_TYPE (t))))
{
struct constraint_expr lhsc, rhsc;
Index: gcc/testsuite/g++.dg/tree-ssa/restrict2.C
===================================================================
*** gcc/testsuite/g++.dg/tree-ssa/restrict2.C (revision 228014)
--- gcc/testsuite/g++.dg/tree-ssa/restrict2.C (working copy)
*************** f5 (S *__restrict x, S *__restrict y)
*** 45,52 ****
{
x->p[0] = 5;
y->p[0] = 0;
! // We might handle this some day
! // { dg-final { scan-tree-dump-times "return 5" 1 "optimized" { xfail *-*-* }
} }
return x->p[0];
}
--- 45,51 ----
{
x->p[0] = 5;
y->p[0] = 0;
! // { dg-final { scan-tree-dump-times "return 5" 1 "optimized" } }
return x->p[0];
}