[PATCH] D75285: Mark restrict pointer or reference to const as invariant
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 27 13:30:33 PST 2020
yaxunl added a comment.
In D75285#1896400 <https://reviews.llvm.org/D75285#1896400>, @hfinkel wrote:
> Unfortunately, we cannot do this kind of thing just because it seems to make sense. The language semantics must be exactly satisfied by the IR-level semantics. I certainly agree that it would make sense for users to be able to mark invariant loads, but this mechanism simply might not be the right one.
>
> One problem here is that, with something like:
>
> char test2(X *x) {
> const char* __restrict p = &(x->b);
> return *p;
> }
>
>
> what happens when the function is inlined? Does the "invariantness" only still apply to accesses within the scope of the local restrict pointer? I believe that it would not, and that would be a problem because later code might legally modify the relevant data.
How about inserting llvm.invariant.end at the end of scope of the variable?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75285/new/
https://reviews.llvm.org/D75285
More information about the cfe-commits
mailing list