From nobody Wed Dec 22 10:05:44 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 97DE61905584; Wed, 22 Dec 2021 10:05:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JJpqZ496Yz4YDq; Wed, 22 Dec 2021 10:05:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7894C1B5F4; Wed, 22 Dec 2021 10:05:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BMA5itZ091754; Wed, 22 Dec 2021 10:05:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BMA5ivH091753; Wed, 22 Dec 2021 10:05:44 GMT (envelope-from git) Date: Wed, 22 Dec 2021 10:05:44 GMT Message-Id: <202112221005.1BMA5ivH091753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 66ef1ce5b399 - stable/12 - r356104 | jhibbits | 2019-12-27 00:06:28 +0100 (Fri, 27 Dec 2019) | 25 lines List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 66ef1ce5b3998bfd0cd7b1664f52a5f559eafde8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640167546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZkyN1tzj+2B/e2FWRbNio9j4FujNc+UIheh/EotniAI=; b=fOjnuUQ5qdEx/lKbXIYziwusaZu71UR0R7h1uJ0GfElrlJfV70XrpQZ9Zl6ZcPagrbJuDK hBC18jUBNneS4O+7xTbZ6WAyNrz0kcTku7TaPg16IoMxf2L/kcfZmun3FU3HzwS6ac9pu3 bnwi2oMnf/3fBnV4Y/5VltVHhx4J+e59JGjyyCCJOClSqz8NzFZJkFJ0W8WPSiMy942ip8 zRNWl8ObEiBNiXu6QbSqSbK4ql2jk9vuPWYQCua+EBIYdKJHDdUMOzbtY5YQiIiYnE8u3v lBKsTBjF80fnhizGNLBfIb4tL4Y0YJRil25uuV2CcbjJOOXvuok5BTiLznQ/gg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640167546; a=rsa-sha256; cv=none; b=Hb7XJb4IJsWrl7z8Ok0Az0OKJMhnZBP4MA3649FWMrj1DLvfSNAQr24kJkZmMW672jCKMx 87lI/h9nPoiePg8ZUNLwJivyxAjRp07ytsW9ZXpJMxz3xXM1PcjHqLSXyene/doroF/ycM eRNS/jNnRmc26iaQ/ZiMB0OPp5+w4J7FOlI4/qQAn7oAmCZvWCxWHY8tavRdHgJM4npDq7 LDc0gFzirra9B2SGte4+FGKSHH+b/sM9fRPPXnAlxo//2zTLz4MqNuEoT7mt55iVjVWJFN 2prjZygovVHQ8dJVr6jLaBTsfoKfJIlg0KRVyoiALV3/5p6SuWhKiCYaTmZEZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=66ef1ce5b3998bfd0cd7b1664f52a5f559eafde8 commit 66ef1ce5b3998bfd0cd7b1664f52a5f559eafde8 Author: Dimitry Andric AuthorDate: 2020-08-06 19:11:24 +0000 Commit: Dimitry Andric CommitDate: 2021-12-22 09:58:21 +0000 r356104 | jhibbits | 2019-12-27 00:06:28 +0100 (Fri, 27 Dec 2019) | 25 lines [PowerPC] enable atomic.c in compiler_rt and do not check and forces lock/lock_free decisions in compiled time Summary: Enables atomic.c in compiler_rt and forces clang to not emit a call for runtime decision about lock/lock_free. At compiling time, if clang can't decide if atomic operation can be lock free, it emits calls to external functions like `__atomic_is_lock_free`, `__c11_atomic_is_lock_free` and `__atomic_always_lock_free`, postponing decision to a runtime check. According to LLVM code documentation, the mechanism exists due to differences between x86_64 processors that can't be decided at runtime. On PowerPC and PowerPCSPE (32 bits), we already know in advance it can't be lock free, so we force the decision at compile time and avoid having to implement it in an external library. This patch was made after 32 bit users testing the PowePC32 bit ISO reported llvm could not be compiled with in-base llvm due to `__atomic_load8` not implemented. Submitted by: alfredo.junior_eldorado.org.br Reviewed by: jhibbits, dim Differential Revision: https://reviews.freebsd.org/D22549 (cherry picked from commit 0faeaeed40a4c42a778a088cbdad0bc54468eef4) --- contrib/llvm-project/clang/lib/AST/ExprConstant.cpp | 7 +++++++ contrib/llvm-project/compiler-rt/lib/builtins/atomic.c | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp index 41a4ae4b91c8..97d5d7bb2180 100644 --- a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp +++ b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp @@ -11529,6 +11529,13 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, } } + // Avoid emiting call for runtime decision on PowerPC 32-bit + // The lock free possibilities on this platform are covered by the lines + // above and we know in advance other cases require lock + if (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); } diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c index 8634a72e77d1..2a69101fbcee 100644 --- a/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c +++ b/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c @@ -120,13 +120,20 @@ static __inline Lock *lock_for_pointer(void *ptr) { 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__) +#define IS_LOCK_FREE_8 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