This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/62171] restrict pointer to struct with restrict pointers parm doesn't prevent aliases


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62171

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]