[PATCH] D123642: [clang codegen] Assume arguments of __atomic_* are aligned.

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 15 11:59:51 PDT 2022


jyknight added a comment.

In D123642#3450110 <https://reviews.llvm.org/D123642#3450110>, @efriedma wrote:

>> I disagree with this on principle -- IMO, it is basically a historical bug in GCC that it ignores the type alignment, and we should NOT try to match that -- it's dangerous.
>
> gcc has always behaved this way, and I don't see any indication they intend to change it.  I mean, you can call it a bug, but at the end of the day the bug reports will land in our bugtracker, not gcc's.

Have we had many other such bug reports?

On the other hand, I have seen many cases where people wrote code using the `__atomic_*` APIs, and pass arguments which are underaligned on some platforms (though not the one the code was developed on). Having it be silently non-atomic (which is what typically happens with misaligned atomic instructions) is just...really nasty.

>> Ask GCC to modify libstdc++ so that `__builtin_addressof` is called directly, instead of going through `std::__addressof`.
>
> Even if gcc did this today, it would take years to reach people on Linux.

True, but the behavior in the meantime is correct. And given the apparent lack of widespread issues, I'm not sure it much matters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123642



More information about the cfe-commits mailing list