[compiler-rt] dd20323 - [compiler-rt builtins] Assert that atomic.c can be compiled correctly.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 14:41:16 PDT 2022


Author: Eli Friedman
Date: 2022-05-16T14:40:57-07:00
New Revision: dd20323f51b676bd0f13c82dc1587e8afcdd527a

URL: https://github.com/llvm/llvm-project/commit/dd20323f51b676bd0f13c82dc1587e8afcdd527a
DIFF: https://github.com/llvm/llvm-project/commit/dd20323f51b676bd0f13c82dc1587e8afcdd527a.diff

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

The spinlock requires that lock-free operations are available;
otherwise, the implementation just calls itself. As discussed in
D120026.

Differential Revision: https://reviews.llvm.org/D123080

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c
index 4c3ebb99a5136..6d54b61f6410f 100644
--- a/compiler-rt/lib/builtins/atomic.c
+++ b/compiler-rt/lib/builtins/atomic.c
@@ -92,6 +92,8 @@ __inline static void lock(Lock *l) { OSSpinLockLock(l); }
 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) {


        


More information about the llvm-commits mailing list