summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2022-06-01 12:56:37 -0400
committerTom Stellard <tstellar@redhat.com>2022-06-07 17:38:05 -0700
commit483db58f3eb5c625615e212283800cea2cb04b3e (patch)
tree8f7d1bb64c72415fbea15766e6b73b5eeb23fa1e
parent576e5b39ae4d4bab8c8f3456a0d6b37bb46dfdb7 (diff)
downloadllvm-483db58f3eb5c625615e212283800cea2cb04b3e.tar.gz
compiler-rt: Allow build without __c11_atomic_fetch_nand
Don't build atomic fetch nand libcall functions when the required compiler builtin isn't available. Without this compiler-rt can't be built with LLVM 13 or earlier. Not building the libcall functions isn't optimal, but aligns with the usecase in FreeBSD where compiler-rt from LLVM 14 is built with an LLVM 13 clang and no LLVM 14 clang is built. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D126710 (cherry picked from commit 18efa420da5fa065d88ba451cdcdbd950a2090c1)
-rw-r--r--compiler-rt/lib/builtins/atomic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c
index 4c3ebb99a513..8dc2f4fc013a 100644
--- a/compiler-rt/lib/builtins/atomic.c
+++ b/compiler-rt/lib/builtins/atomic.c
@@ -363,6 +363,9 @@ OPTIMISED_CASES
#define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW(n, lockfree, type, xor, ^)
OPTIMISED_CASES
#undef OPTIMISED_CASE
+// Allow build with clang without __c11_atomic_fetch_nand builtin (pre-14)
+#if __has_builtin(__c11_atomic_fetch_nand)
#define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type)
OPTIMISED_CASES
#undef OPTIMISED_CASE
+#endif