This is the mail archive of the gcc@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]

Restrict implementation considered harmful


With looking at PRs 37742 and 37955 I reminded myself of our broken
restrict implementation which tries to model restrict semantics
within our type-based alias set framework.  The implementation
heavily relies on correct tracking of restrict bases
(DECL_BASED_ON_RESTRICT_P/DECL_GET_RESTRICT_BASE) - but this
is completely bogus even for trivial testcases like

int foo (int *__restrict p)
{
  int *__restrict q;
  int v;
  q = p + 1;
  q = q - 1;
  v = *q;
  *p = 1;
  return v + *q;
}
extern void abort (void);
int main()
{
  int i = 0;
  if (foo (&i) != 1)
    abort ();
  return 0;
}

where q is not set to be based on p (and in general with SSA form
its impossible to properly track this as the information is per
decl, not per SSA nae).

Luckily no single tree pass looks at the alias set of an indirect ref
but on the alias sets of the pointed-to types.  Which makes the
special restrict pointer handling in get_alias_set ineffective.

Now, tree-vect-transform.c does - to verify that the new memory
reference conflicts with the old one.  But this verification
obviously fails here because of the missing links.

I think the only reasonable thing to do is to rip out the broken
restrict pointer handling completely.

Any better ideas?

Thanks,
Richard.


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