From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29576 invoked by alias); 22 Sep 2015 08:01:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29538 invoked by uid 48); 22 Sep 2015 08:01:22 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/62171] restrict pointer to struct with restrict pointers parm doesn't prevent aliases Date: Tue, 22 Sep 2015 08:01:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg01759.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62171 --- Comment #7 from Richard Biener --- 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.