[PATCH] D99791: [CGCall] Annotate pointer argument with alignment
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 6 16:14:26 PDT 2021
rjmccall added a comment.
In D99791#2672528 <https://reviews.llvm.org/D99791#2672528>, @lebedev.ri wrote:
> @rjmccall thank you for taking a look!
>
> In D99791#2670333 <https://reviews.llvm.org/D99791#2670333>, @rjmccall wrote:
>
>> The last major conversation we had about this was this RFC I sent out about five years ago:
>>
>> https://lists.llvm.org/pipermail/llvm-dev/2016-January/094012.html
>>
>> In that RFC, I specifically argued that we should not do this, and that it should only be considered undefined behavior to actually access memory through a misaligned pointer (for a particular definition of "access memory"). At Apple, we have made that a promise to our internal users, so even if we decide to do this, we will need to not do it on Darwin. However, as I remember it, the LLVM community did not reach a consensus to adopt my recommendation, so in principle we still have the flexibility to start doing this. I continue to believe that doing so would be a mistake. At any rate, you should start by reading that thread.
>
> Thank you for the pointer!
> I can for sure provide an opt-out, however note that in the end it will cause performance regressions as compared to the current LLVM optimizations.
How so? We do not currently assume that pointer arguments are aligned, or even dereferenceable.
I don't mind making stronger assumptions about the C++ `this` argument, but we really should not do this for arbitrary pointer arguments. If you want to put together a UBSan mode that checks this, that's fine, but I do not think there is a path forward for actually optimizing based on this assumption by default.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99791/new/
https://reviews.llvm.org/D99791
More information about the cfe-commits
mailing list