[PATCH] D123080: [compiler-rt builtins] Assert that atomic.c can be compiled correctly.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 14:53:25 PDT 2022


efriedma created this revision.
efriedma added a reviewer: alanphipps.
Herald added a subscriber: dberris.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

The spinlock requires that lock-free operations are available; otherwise, the implementation just calls itself. As discussed in D120026 <https://reviews.llvm.org/D120026>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123080

Files:
  compiler-rt/lib/builtins/atomic.c


Index: compiler-rt/lib/builtins/atomic.c
===================================================================
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -92,6 +92,8 @@
 static Lock locks[SPINLOCK_COUNT]; // initialized to OS_SPINLOCK_INIT which is 0
 
 #else
+_Static_assert(__atomic_always_lock_free(sizeof(uintptr_t), 0),
+               "Implementation assumes lock-free pointer-size cmpxchg");
 typedef _Atomic(uintptr_t) Lock;
 /// Unlock a lock.  This is a release operation.
 __inline static void unlock(Lock *l) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123080.420315.patch
Type: text/x-patch
Size: 557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220404/03cefb83/attachment.bin>


More information about the llvm-commits mailing list