[llvm-dev] Why is remalloc not marked as noalias?
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 9 02:03:27 PST 2018
On 9 Jan 2018, at 03:39, Hal Finkel <hfinkel at anl.gov> wrote:
>> This is problematic with noalias, because if the result of realloc is guaranteed never to alias with any existing pointer then this comparison is trivially true. This won’t break any of the code that I’ve seen, but it will mean that we’re optimising away the fast path and leaving only the slow path (which doesn’t quite accord with how most programmers understand the notion of optimisation).
> Because in general we can't (and don't) use noalias to decide on pointer equality, we won't optimize away the comparison. I think we're okay in this regard.
This seems like a missed optimisation opportunity, and I’m hesitant about adding incorrect metadata on the basis that we don’t yet optimise based on it. If a and b don’t alias, then that implies a != b. If a and b do alias, then that doesn’t imply that a == b (because they might be pointers to different offsets in the same object), but there should be no way for a pointer to definitely not alias with itself.
If we do have a definition of alias such that it’s possible for a to definitely not alias with a, then I think we should probably add a detailed description of what it means to the language ref.
More information about the llvm-dev