[PATCH] D47553: Add TargetLowering::shouldExpandAtomicToLibCall and query it from AtomicExpandPass

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 13:28:15 PDT 2018


efriedma added a comment.

Your suggested lowering is illegal according to the API rules for libatomic; for any given size/alignment, either all operations are lock-free, or all operations use locks.  Otherwise, atomics aren't threadsafe.  See also https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary.

ARM Linux gets around this issue by lowering atomic cmpxchg to call __sync_val_compare_and_swap_4 etc. instead; the implementation uses a special lock-free helper provided by the kernel.  See https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt .


Repository:
  rL LLVM

https://reviews.llvm.org/D47553





More information about the llvm-commits mailing list