[PATCH] D75285: Mark restrict pointer or reference to const as invariant

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 10:39:13 PST 2020


Anastasia added a comment.

In D75285#1903611 <https://reviews.llvm.org/D75285#1903611>, @yaxunl wrote:

> In D75285#1903444 <https://reviews.llvm.org/D75285#1903444>, @rjmccall wrote:
>
> > That is not true for two reasons: first, `restrict` guarantees that the variable is not accessed through any non-derived l-value within its scope, and that would certainly include from other threads; and second, it is undefined behavior for two threads to access the same object without synchronizing anyway (unless they're both just reading from it).
>
>
> How about the cases where users cannot use restrict but they still want to mark a pointer as invariant? Or even though restrict is used but it is too complicated for alias analysis to deduce invariance?


If we can reuse existing attributes it is better than adding new ones so my preference would be to make `restrict` work unless it's absolutely impossible for the use case you consider.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75285/new/

https://reviews.llvm.org/D75285





More information about the cfe-commits mailing list