From nobody Fri May 29 23:04:31 2026 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 4gRzSw4zBCz6gFd6 for ; Fri, 29 May 2026 23:04:32 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gRzSv6yCMz3HNy for ; Fri, 29 May 2026 23:04:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780095872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Z1OOULOJ9ITPka+PlQEiB1LVOJJ0yjeXV+GMj3bWfBU=; b=sJg2H3MC18PSNy10j9Vl5kecPI/ApIC5LLNln9xXikAGVhbiKB7cRAq5DHnLcI3XEYKmNJ yGzCyUZwsp032SuxFWdg1tkOvR6fShzit0LqrGFLae+qq4MlympyMwLrg9Qkm6vlPc79vW adbUVnYQlfZRBe+nzkpDRqzN8n7KGDHIu8NYMa9L/j6zOb1109PZMcTx6reg+AVv3YH5Um QAd7KzU2HOREoZ5W/Oz9vryGjxoMOHY4ESLq5Lz9MRqA2srv8wSGKzO5DDmjHM6jQjuDXy UpExkOOEPO0YlyC+V5b9QlJlvSHbDlkIHuzozXkKlW+XutXE0Qs/xrXutrFzEg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780095872; a=rsa-sha256; cv=none; b=dE53+EoIg1xawXPK9VeLxnpdUD1dRPGKtFDlqLLN4K8fyS8GveOsgxMv5bRpMi1LSK25jW cInKj3rZ+3UrdcyWsqaCOJxx7tVyF33ghIhPwKUzdVUze83yEgQX07HYo+HVfgzeo6KKI8 GN/43qxyz3517rwd7wGGcSvCQgMOxFBXvhNnJPZtrVJK3oMmx5Aq9ZQs9LJN8JDJiOapPk LEnbm2KrXq6VCe0inuq1ipRFbGvQYFNsBjDkhk1rjQF39ztuS8zLGC1VZl8BHcw9LstuNP t+kL6bSEnhLbm+MXKdVI1wV9sW679bwpfGmhcWvsV0SBPDsmoVh2F2XvuVbJog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780095872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Z1OOULOJ9ITPka+PlQEiB1LVOJJ0yjeXV+GMj3bWfBU=; b=KarCfYq0Nl4uIpdTa241uA/FdYR9fFij0VrTyQyI+fTUJ/TKd8Cpdv5FPQctRmjiyEiG19 BBCqIryZXj38r1TyqYZo/w2zq8zK5vlS89PxwRlFbCVsA0vyt4KXtuxqOiRmpIrakT5Hj4 L9tX2eRhi3kC+o585PKoBMmKRntBnkWHEihzJUWo3JbB06YwBkNeFTO2ieKhJLW/EMN1Nv 2sVbFRxGVMmh3vEkIdf2dDKiR+4LNr91V8ogoQeUpg5N4OVeosVxAex1iOLQg0iTXyLZLL Z0iIvsY1ffMrMjeWZ5C+mD+fwu6GeOMzm0XfJaZQWTc52uaPs/JzxVYWEPmBPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gRzSv6YYkztjF for ; Fri, 29 May 2026 23:04:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4248f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 29 May 2026 23:04:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Dimitry Andric From: Dimitry Andric Subject: git: 7a145cbf09ae - stable/14 - libcxx-compat: revert llvmorg-21-init-9130-g9e3982d9ae81: 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/14 X-Git-Reftype: branch X-Git-Commit: 7a145cbf09aefe989dcb06047f9d3b3be2557fef Auto-Submitted: auto-generated Date: Fri, 29 May 2026 23:04:31 +0000 Message-Id: <6a1a1b7f.4248f.bc18175@gitrepo.freebsd.org> The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=7a145cbf09aefe989dcb06047f9d3b3be2557fef commit 7a145cbf09aefe989dcb06047f9d3b3be2557fef Author: Dimitry Andric AuthorDate: 2026-01-04 19:43:38 +0000 Commit: Dimitry Andric CommitDate: 2026-05-29 22:59:36 +0000 libcxx-compat: revert llvmorg-21-init-9130-g9e3982d9ae81: [libc++] Replace __libcpp_{ctz, clz} with __builtin_{ctzg, clzg} (#133920) `__libcpp_{ctz, clz}` were previously used as fallbacks for `__builtin_{ctzg, clzg}` to ensure compatibility with older compilers (Clang 18 and earlier), as `__builtin_{ctzg, clzg}` became available in Clang 19. Now that support for Clang 18 has been officially dropped in #130142, we can now safely replace all instances of `__libcpp_{ctz, clz}` with `__count{l,r}_zero` (which internally call `__builtin_{ctzg, clzg}` and eliminate the fallback logic. Closes #131179. This is part of making libc++ 21 build with clang 18. PR: 292067 MFC after: 1 month (cherry picked from commit 821fc643b3cad922e5438760eed9cad0d6d9b3b0) --- contrib/llvm-project/libcxx/include/__bit/countl.h | 28 ++++++++++++++++++ contrib/llvm-project/libcxx/include/__bit/countr.h | 33 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/contrib/llvm-project/libcxx/include/__bit/countl.h b/contrib/llvm-project/libcxx/include/__bit/countl.h index 075914020879..11de5f214682 100644 --- a/contrib/llvm-project/libcxx/include/__bit/countl.h +++ b/contrib/llvm-project/libcxx/include/__bit/countl.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___BIT_COUNTL_H #define _LIBCPP___BIT_COUNTL_H +#include <__bit/rotate.h> #include <__config> #include <__type_traits/integer_traits.h> #include @@ -25,7 +26,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { static_assert(__is_unsigned_integer_v<_Tp>, "__countl_zero requires an unsigned integer type"); +#if __has_builtin(__builtin_clzg) return __builtin_clzg(__t, numeric_limits<_Tp>::digits); +#else // __has_builtin(__builtin_clzg) + if (__t == 0) + return numeric_limits<_Tp>::digits; + + if (sizeof(_Tp) <= sizeof(unsigned int)) + return __builtin_clz(static_cast(__t)) - + (numeric_limits::digits - numeric_limits<_Tp>::digits); + else if (sizeof(_Tp) <= sizeof(unsigned long)) + return __builtin_clzl(static_cast(__t)) - + (numeric_limits::digits - numeric_limits<_Tp>::digits); + else if (sizeof(_Tp) <= sizeof(unsigned long long)) + return __builtin_clzll(static_cast(__t)) - + (numeric_limits::digits - numeric_limits<_Tp>::digits); + else { + int __ret = 0; + int __iter = 0; + const unsigned int __ulldigits = numeric_limits::digits; + while (true) { + __t = std::__rotl(__t, __ulldigits); + if ((__iter = std::__countl_zero(static_cast(__t))) != __ulldigits) + break; + __ret += __iter; + } + return __ret + __iter; + } +#endif // __has_builtin(__builtin_clzg) } #if _LIBCPP_STD_VER >= 20 diff --git a/contrib/llvm-project/libcxx/include/__bit/countr.h b/contrib/llvm-project/libcxx/include/__bit/countr.h index f6c98695d3d0..2179eeae9e3d 100644 --- a/contrib/llvm-project/libcxx/include/__bit/countr.h +++ b/contrib/llvm-project/libcxx/include/__bit/countr.h @@ -22,10 +22,43 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD +// A constexpr implementation for C++11 and later (using clang extensions for constexpr support) +// Precondition: __t != 0 (the caller __countr_zero handles __t == 0 as a special case) +template +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero_impl(_Tp __t) _NOEXCEPT { + _LIBCPP_ASSERT_INTERNAL(__t != 0, "__countr_zero_impl called with zero value"); + static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero_impl only works with unsigned types"); + if _LIBCPP_CONSTEXPR (sizeof(_Tp) <= sizeof(unsigned int)) { + return __builtin_ctz(static_cast(__t)); + } else if _LIBCPP_CONSTEXPR (sizeof(_Tp) <= sizeof(unsigned long)) { + return __builtin_ctzl(static_cast(__t)); + } else if _LIBCPP_CONSTEXPR (sizeof(_Tp) <= sizeof(unsigned long long)) { + return __builtin_ctzll(static_cast(__t)); + } else { +#if _LIBCPP_STD_VER == 11 + unsigned long long __ull = static_cast(__t); + const unsigned int __ulldigits = numeric_limits::digits; + return __ull == 0ull ? __ulldigits + std::__countr_zero_impl<_Tp>(__t >> __ulldigits) : __builtin_ctzll(__ull); +#else + int __ret = 0; + const unsigned int __ulldigits = numeric_limits::digits; + while (static_cast(__t) == 0uLL) { + __ret += __ulldigits; + __t >>= __ulldigits; + } + return __ret + __builtin_ctzll(static_cast(__t)); +#endif + } +} + template [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT { static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero only works with unsigned types"); +#if __has_builtin(__builtin_ctzg) // TODO (LLVM 21): This can be dropped once we only support Clang >= 19. return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); +#else + return __t != 0 ? std::__countr_zero_impl(__t) : numeric_limits<_Tp>::digits; +#endif } #if _LIBCPP_STD_VER >= 20