[PATCH] D156841: [CaptureTracking] Allow non-void `noalias` return funcs to be non-capturing
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 03:56:40 PDT 2023
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.
I don't think this is correct. `noalias` is a provenance concept, while `nocapture` is also about address identity.
For example, realloc-style functions usually also have noalias return, even though they might return the same pointer as their argument. After such a realloc, it is no longer legal to make accesses through the old pointer, even though it has the same address as the new one.
Lets say you have a special realloc function that guarantees that it returns the original pointer (with fresh provenance) if the allocation size does not change. In that case `realloc(p, old_size) == p` must return true, so realloc captures the pointer.
There are some confounding factors here, because we do have at least one optimization that tries to assign address unpredictabliity properties to noalias returns, but I believe the general consensus is that that optimization is buggy, and this should be represented using a separate allocator property instead.
Anyway, what's the motivation for this? I can't come up with an example where you would run into a function that is both noalias and readonly in practice.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156841/new/
https://reviews.llvm.org/D156841
More information about the llvm-commits
mailing list