Index: contrib/compiler-rt/lib/builtins/atomic.c =================================================================== --- contrib/compiler-rt/lib/builtins/atomic.c +++ contrib/compiler-rt/lib/builtins/atomic.c @@ -51,8 +51,8 @@ //////////////////////////////////////////////////////////////////////////////// #ifdef __FreeBSD__ #include -#include #include +#include #include typedef struct _usem Lock; __inline static void unlock(Lock *l) { @@ -117,13 +117,20 @@ return locks + (hash & SPINLOCK_MASK); } -/// Macros for determining whether a size is lock free. Clang can not yet -/// codegen __atomic_is_lock_free(16), so for now we assume 16-byte values are -/// not lock free. +/// Macros for determining whether a size is lock free. #define IS_LOCK_FREE_1 __c11_atomic_is_lock_free(1) #define IS_LOCK_FREE_2 __c11_atomic_is_lock_free(2) #define IS_LOCK_FREE_4 __c11_atomic_is_lock_free(4) + +/// 32 bit PowerPC doesn't support 8-byte lock_free atomics +#if !defined(__powerpc64__) && (defined(__powerpc__) || defined(__powerpcspe__)) +#define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(0) +#else #define IS_LOCK_FREE_8 __c11_atomic_is_lock_free(8) +#endif + +/// Clang can not yet codegen __atomic_is_lock_free(16), so for now we assume +/// 16-byte values are not lock free. #define IS_LOCK_FREE_16 0 /// Macro that calls the compiler-generated lock-free versions of functions Index: contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp =================================================================== --- contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp +++ contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp @@ -9896,8 +9896,16 @@ } } + // Don't emit call to external __atomic_always_lock_free for + // target FreeBSD on PowerPC 32-bit + if (Info.Ctx.getTargetInfo().getTriple().isOSFreeBSD() && + Info.Ctx.getTargetInfo().getTriple().getArch() == llvm::Triple::ppc) { + return Success(0, E); + } + return BuiltinOp == Builtin::BI__atomic_always_lock_free ? Success(0, E) : Error(E); + } case Builtin::BIomp_is_initial_device: // We can decide statically which value the runtime would return if called. Index: lib/libcompiler_rt/Makefile.inc =================================================================== --- lib/libcompiler_rt/Makefile.inc +++ lib/libcompiler_rt/Makefile.inc @@ -205,6 +205,14 @@ SRCF+= stdatomic .endif + +.if "${COMPILER_TYPE}" == "clang" && \ + (${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpcspe") +SRCS+= atomic.c +CFLAGS.atomic.c+= -Wno-atomic-alignment +.endif + + .for file in ${SRCF} .if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \ && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)