From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5547 invoked by alias); 20 Aug 2014 09:15:38 -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 5477 invoked by uid 48); 20 Aug 2014 09:15:29 -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: Wed, 20 Aug 2014 09:15: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-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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: 2014-08/txt/msg01342.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62171 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #1 from Richard Biener --- Our restrict support doesn't handle this case. Note that I don't think the C standard defines what happens with restrict qualified data members. What is the "pointer" that is used for all the "based-on" wording? What is the "scope" of it? Special-casing this very special case in points-to is possible, we already have code to do that but it is "restricted" (heh). static void intra_create_variable_infos (struct function *fn) { tree t; /* For each incoming pointer argument arg, create the constraint ARG = NONLOCAL or a dummy variable if it is a restrict qualified passed-by-reference argument. */ for (t = DECL_ARGUMENTS (fn->decl); t; t = DECL_CHAIN (t)) { 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)))) { ... which was implemented to support Fortran array descriptors with restrict qualified data pointer. So if you say we can treat any T * restrict parameter in that way (no other global(!) or function parameter pointer may be used to access the memory the fields in the struct pointed to by the parameter), then fine. Note that we restrict this to REFERENCEs as pointers may point to an array of objects which I think we don't treat correctly here (we need to know the size of the object - with a pointer you can even access sth before what we point to). This means supporting this may be difficult. It may already work if you use C++ and static double __attribute__((noinline, noclone)) f (struct omp_data_i &__restrict__ p, int argc) { ? That is, if the middle-end uses a REFERENCE_TYPE?