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

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 13 14:53:00 PDT 2022


efriedma added a comment.

> 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.

> As a workaround: add alignas(uint64_t) to the affected struct in lld. (is GHashCell the only one?)

I think that's the only one, at least according to `git grep std::atomic`; I guess that works.  (Assuming you meant `alignas(sizeof(uint64_t))`.)

> 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.

I guess this is motivation to implement namespaced builtins...?


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