[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 7 16:20:57 PDT 2018


rsmith added inline comments.


================
Comment at: lib/CodeGen/CGAtomic.cpp:949
     case AtomicExpr::AO__opencl_atomic_compare_exchange_strong:
     case AtomicExpr::AO__atomic_load_n:
     case AtomicExpr::AO__atomic_store_n:
----------------
efriedma wrote:
> Is there any particular reason to expect that the pointer operand to __atomic_load_n can't be misaligned?  I mean, for most ABIs, integers are naturally aligned, but that isn't actually a hard rule.
`__atomic_load_n` is, by definition, guaranteed to never call an unoptimized atomic library function (see https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary). [I think the purpose of the `..._n` variants is to provide builtins that libatomic's unoptimized library functions can use and have a guarantee that they will not be recursively re-entered.]


Repository:
  rC Clang

https://reviews.llvm.org/D51817





More information about the cfe-commits mailing list