| author | |
| committer | |
| log | 820dc9d76726ab9148b49630a1b4371624032918 |
| tree | 23be73211c3f0fc58fd9b0fc37b4dc8d56ccd95f |
| parent | 958faa7031c7b50a544e151fea4d486e1c4926c1 |
| signature |
https://github.com/llvm/llvm-project/pull/1554763 files changed, 8 insertions(+), 0 deletions(-)
lib/libcxx/include/__algorithm/sort.h+3| ... | ... | @@ -860,6 +860,9 @@ __sort<__less<long double>&, long double*>(long double*, long double*, __less<lo |
| 860 | 860 | template <class _AlgPolicy, class _RandomAccessIterator, class _Comp> |
| 861 | 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 862 | 862 | __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { |
| 863 | if (__first == __last) // log(0) is undefined, so don't try computing the depth | |
| 864 | return; | |
| 865 | ||
| 863 | 866 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 864 | 867 | difference_type __depth_limit = 2 * std::__bit_log2(std::__to_unsigned_like(__last - __first)); |
| 865 | 868 |
lib/libcxx/include/__bit/bit_log2.h+2| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___BIT_BIT_LOG2_H |
| 10 | 10 | #define _LIBCPP___BIT_BIT_LOG2_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 12 | 13 | #include <__bit/countl.h> |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <__type_traits/integer_traits.h> |
| ... | ... | @@ -23,6 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | template <class _Tp> |
| 24 | 25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __bit_log2(_Tp __t) _NOEXCEPT { |
| 25 | 26 | static_assert(__is_unsigned_integer_v<_Tp>, "__bit_log2 requires an unsigned integer type"); |
| 27 | _LIBCPP_ASSERT_INTERNAL(__t != 0, "logarithm of 0 is undefined"); | |
| 26 | 28 | return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t); |
| 27 | 29 | } |
| 28 | 30 |
lib/libcxx/src/algorithm.cpp+3| ... | ... | @@ -13,6 +13,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 13 | 13 | |
| 14 | 14 | template <class Comp, class RandomAccessIterator> |
| 15 | 15 | void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) { |
| 16 | if (first == last) // log(0) is undefined, so don't try computing the depth | |
| 17 | return; | |
| 18 | ||
| 16 | 19 | auto depth_limit = 2 * std::__bit_log2(static_cast<size_t>(last - first)); |
| 17 | 20 | |
| 18 | 21 | // Only use bitset partitioning for arithmetic types. We should also check |