This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/62171] restrict pointer to struct with restrict pointers parm doesn't prevent aliases
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Sep 2015 08:01:18 +0000
- Subject: [Bug tree-optimization/62171] restrict pointer to struct with restrict pointers parm doesn't prevent aliases
- Auto-submitted: auto-generated
- References: <bug-62171-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62171
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I was thinking about sth like
struct X { int i; int * __restrict__ q; };
int foo (X& __restrict__ x, X *p)
{
*x.q = 1;
p->i = 0;
return *x.q;
}
int main()
{
X x;
x.q = &x.i;
return foo (x, &x);
}
but I see we're still conservatively requiring decls in visit_loadstore:
tree ptr = TREE_OPERAND (base, 0);
if (TREE_CODE (ptr) == SSA_NAME)
{
/* ??? We need to make sure 'ptr' doesn't include any of
the restrict tags in its points-to set. */
return false;
Of course this kind of testcase would also break if X were passed by
value (and changed by the frontend to DECL_BY_REFERENCE). That is,
using the 2nd level restrict sounds bogus iff there can be a testcase
that can be created by the user (thus is not under strict control by
the compiler).
That said, generally the tree-ssa-structalias.c:visit_loadstore needs
some more sophistication as well.