6707 Commits

Author SHA1 Message Date
A. Jiang
026210e80d
[libc++][ranges] P2609R3: Relaxing Ranges Just A Smidge (#101715)
This patch implements https://wg21.link/p2609r3.
The test code was originally authored by JMazurkiewicz.

Notes:
- P2609R3 is not officially a Defect Report, but MSVC STL
  implements it in C++20 mode.

  Moreover, P2609R3 and P2997R1 touch exactly the same set of
  concepts, and MSVC STL and libc++ have already treated P2997R1
  as a DR.

- This patch also adjusted feature-test macros.
  + In C++20 mode, the value of __cpp_lib_ranges should be `202110L` because
    - `202202L` covers `range_adaptor_closure` (P2387R3), and
    - `202207L` covers move-only types in range adaptors (P2494R2).
  And all of these changes are only available since C++23 mode.

  + In C++23 mode, the value should be `202406L` because
    - `202211L` covers removing poison overloads (P2602R2),
    - `202302L` covers relaxing projected value types (P2609R3), and
    - `202406L` covers removing requirements on `iter_common_reference_t` (P2997R1).
  And all of these changes are already or being implemented.

Fixes #105253.

Co-authored-by: Jakub Mazurkiewicz <mazkuba3@gmail.com>
2024-08-28 08:55:44 -04:00
Robin Caloudis
866bec7d3f
[libc++][math] Provide overloads for cv-unqualified floating point types for std::isnormal (#104773)
## Why
Currently, the following does not work when compiled with clang:

```c++
#include <cmath>

struct ConvertibleToFloat {
    operator float();
};

bool test(ConvertibleToFloat x) {
    return std::isnormal(x);
}
```
See https://godbolt.org/z/5bos8v67T for differences with respect to
msvc, gcc or icx. It fails for `float`, `double` and `long double` (all
cv-unqualified floating-point types).

## What
Test and provide overloads as expected by the ISO C++ standard. The
classification/comparison function `isnormal` is defined since C++11
until C++23 as
```c++
bool isnormal( float num );
bool isnormal( double num );
bool isnormal( long double num );
```
and since C++23 as
```c++
constexpr bool isnormal( /* floating-point-type */ num );
```
for which "the library provides overloads for all cv-unqualified
floating-point types as the type of the parameter num". See §28.7.1/1 in
the [ISO C++
standard](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf)
or check
[cppreference](https://en.cppreference.com/w/cpp/numeric/math/isnormal).
2024-08-28 10:34:47 +02:00
A. Jiang
4ea2c73886
[libc++] Deprecate and remove std::uncaught_exception (#101830)
Works towards P0619R4/#99985.

- std::uncaught_exception was not previously deprecated. This patch
  deprecates it since C++17 as per N4259. std::uncaught_exceptions is
  used instead as libc++ unconditionally provides this function.

- _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION restores
  std::uncaught_exception.

- As a drive-by, this patch updates the C++20 status page to 
  explain that D.11 is already done, since it was done in 
  578d09c1b195d859ca7e62840ff6bb83421a77b5.
2024-08-27 17:15:03 -04:00
A. Jiang
74e70bae15
[libc++] Disallow character types being index types of extents (#105832)
#78086 provided the trait we want to use for this: `__libcpp_integer`.

In some `libcxx/containers/views/mdspan` tests, improper uses of `char` 
are replaced with `signed char`. 

Fixes #73715
2024-08-27 16:41:55 -04:00
Louis Dionne
06edc1c07b
[libc++] Avoid including <__config> directly in the test suite (#106080)
Fixes #105878
2024-08-26 17:52:33 -04:00
Louis Dionne
0f58ab851c [libc++] Undo unintended renaming in bc695f522743
Renaming the test will require fixing additional issues, which
I will tackle in a separate patch.
2024-08-26 11:51:29 -04:00
Stephan T. Lavavej
bc695f5227
[libc++][test] Add missing <concepts> in is_always_lock_free test (#105966)
That test was using std::same_as without including <concepts>.
2024-08-26 11:49:47 -04:00
S. B. Tam
499e13514a
[libc++][test] Do not test Clang bug in is_constructible.pass.cpp (#105964)
A comment in `is_constructible.pass.cpp` suggests that Clang is
non-conforming in accepting construction of `const int&` from
`ExplicitTo<int&&>`.

This PR changes the test to expect the standard-conforming behavior,
which makes the test pass on MSVC.
2024-08-26 10:08:52 -04:00
Louis Dionne
1c48c9cc43
[libc++] Implement P2985R0: std::is_virtual_base_of (#105847)
This trait is implemented in C++26 conditionally on the compiler
supporting the __builtin_is_virtual_base_of intrinsic. I believe only
tip-of-trunk Clang currently implements that builtin.

Closes #105432
2024-08-26 09:58:19 -04:00
Stephan T. Lavavej
886b76128f
[libc++][test] Fix msvc_is_lock_free_macro_value() (#105876)
Followup to #99570.

* `TEST_COMPILER_MSVC` must be tested for `defined`ness, as it is
everywhere else.
+ Definition:
52a7116f5c/libcxx/test/support/test_macros.h (L71-L72)
+ Example usage:
52a7116f5c/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp (L248)
+ Fixes: `llvm-project\libcxx\test\support\atomic_helpers.h(33): fatal
error C1017: invalid integer constant expression`
* Fix bogus return type: `msvc_is_lock_free_macro_value()` returns `2`
or `0`, so it needs to return `int`.
+ Fixes: `llvm-project\libcxx\test\support\atomic_helpers.h(41): warning
C4305: 'return': truncation from 'int' to 'bool'`
* Clarity improvement: also add parens when mixing bitwise with
arithmetic operators.
2024-08-24 09:55:17 -07:00
Haowei
e31322ba59
[libc++] Fix transform_error.mandates.verify.cpp test on msvc (#104635)
PR #102851 marks reference types in union as error on msvc by changing
the clang, which makes 'transform_error.mandates.verify.cpp' no longer
failing on msvc from ToT. However, all libcxx buildbots do not build
clang from source, therefore, this test will still fail on these bots,
which is incorrect. This patch changed the expected error message of
this test so it can pass with both release branch clang and ToT clang.
2024-08-22 13:37:59 -04:00
Vladimir Vereschaka
4a2a1b51cb
[libc++] Adjust armv7 XFAIL target triple for the setfill_wchar_max test. (#105586)
Also allow XFAIL for armv7-*-linux-gnueabihf targets, not only for
armv7l-*.
2024-08-22 10:09:03 -07:00
Nikolas Klauser
9ff0468436
[libc++] Refactor the std::unique_lock tests (#102151)
This makes some of the tests not flaky anymore, updates some tests to
also work in C++03 and modernizes them in general.
2024-08-22 11:47:56 +02:00
Louis Dionne
aa08843878
[libc++] Avoid -Wzero-as-null-pointer-constant in operator<=> (#79465)
Issue #43670 describes a situation where the following comparison will
issue a warning when -Wzero-as-null-pointer-constant is enabled:

    #include <compare>
    auto b = (1 <=> 2) < 0;

This code uses operator<(strong_ordering, Unspecified), which is
specified by the Standard to only work with a literal 0. In the library,
this is achieved by constructing Unspecified from a pointer, which works
but has the downside of triggering the warning.

This patch uses an alternative implementation where we require that the
operator is used exactly with an int of value 0 (known at compile-time),
however that value can technically be an expression like `1 - 1`, which
makes us a bit less strict than what's specified in the Standard.

Fixes #43670
2024-08-21 09:05:55 -04:00
Louis Dionne
1e5f275f36
[libc++] Refactor the tests for mutex, recursive mutex and their timed counterparts (#104852)
This refactoring is done to remove flakyness as described in
https://github.com/llvm/llvm-project/pull/89083.
2024-08-21 08:47:22 -04:00
Louis Dionne
f73050e722
[libc++] Fix several double-moves in the code base (#104616)
This patch hardens the "test iterators" we use to test algorithms by
ensuring that they don't get double-moved. As a result of this
hardening, the tests started reporting multiple failures where we would
double-move iterators, which are being fixed in this patch.

In particular:
- Fixed a double-move in pstl.partition
- Add coverage for begin()/end() in subrange tests
- Fix tests for ranges::ends_with and ranges::contains, which were
  incorrectly calling begin() twice on the same subrange containing
  non-copyable input iterators.

Fixes #100709
2024-08-20 14:36:11 -04:00
Joseph Huber
3c603f857c [libcxx][fix] Rename incorrect filename variable
Summary:
This used an old name I forgot to fix, linter didn't catch it because it
was behind `ifdef` and the branch which I tested it on I forgot to
update the one I landed.
2024-08-16 13:50:05 -05:00
Robin Caloudis
2fe59d5259
[libc++][math] Fix acceptance of convertible types in std::isnan() and std::isinf() (#98952)
Following up on https://github.com/llvm/llvm-project/pull/98841.

Changes:
- Properly test convertible types for `std::isnan()` and `std::inf()`
- Tighten conditional in `cmath.pass.cpp` (Find insights on `_LIBCPP_PREFERRED_OVERLOAD` below)
- Tighten preprocessor guard in `traits.h`

Insights into why `_LIBCPP_PREFERRED_OVERLOAD` is needed:

(i) When libc++ is layered on top of glibc on Linux, glibc's `math.h` is
    included. When compiling with `-std=c++03`, this header brings the
    function declaration of `isinf(double)` [1] and `isnan(double)` [2]
    into scope. This differs from the C99 Standard as only the macros
    `#define isnan(arg)` and `#define isinf(arg)` are expected.

    Therefore, libc++ needs to respect the presense of the `double` overload
    and cannot redefine it as it will conflict with the declaration already
    in scope. For `-std=c++11` and beyond this issue is fixed, as glibc
    guards both the `isinf` and `isnan` by preprocessor macros.

(ii) When libc++ is layered on top of Bionic's libc, `math.h` exposes a
     function prototype for `isinf(double)` with return type `int`. This
     function prototype in Bionic's libc is not guarded by any preprocessor
     macros [3].

`_LIBCPP_PREFERRED_OVERLOAD` specifies that a given overload is a better match
than an otherwise equally good function declaration. This is implemented in
modern versions of Clang via `__attribute__((__enable_if__))`, and not elsewhere.
See [4] for details. We use `_LIBCPP_PREFERRED_OVERLOAD` to define overloads in
the global namespace that displace the overloads provided by the C
libraries mentioned above.

[1]: fe94080875/math/bits/mathcalls.h (L185-L194)
[2]: fe94080875/math/bits/mathcalls.h (L222-L231)
[3]: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/math.h;l=322-323;drc=master?hl=fr-BE%22https:%2F%2Fsupport.google.com%2Fmerchants%2Fanswer%2F188494%5C%22%22https:%2F%2Fsupport.google.com%2Fmerchants%2Fanswer%2F188494%5C%22
[4]: 5fd17ab1b0
2024-08-16 11:18:49 -04:00
Louis Dionne
99696b35bc
[libc++] Fix rejects-valid in std::span copy construction (#104500)
Trying to copy-construct a std::span from another std::span holding an
incomplete type would fail as we evaluate the SFINAE for the range-based
constructor. The problem was that we checked for __is_std_span after
checking for the range being a contiguous_range, which hard-errored
because of arithmetic on a pointer to incomplete type.

As a drive-by, refactor the whole test and format it.

Fixes #104496
2024-08-16 11:08:34 -04:00
RichardLuo
aa427b1aae
[libc++] Fix backslash as root dir breaks lexically_relative, lexically_proximate and hash_value on Windows (#99780)
Various functions like hash_value, lexically_proximate and lexically_relative
would incorrectly handle backslashes in the root directory on Windows, causing
behavior that is inconsistent with the equality comparison for a path.
2024-08-16 09:26:38 -04:00
Joseph Huber
f71b638651
[libcxx] Use aligned_alloc for testing instead of posix_memalign (#101748)
Summary:
The `aligned_alloc` function is the C11 replacement for
`posix_memalign`. We should favor the C standard over the POSIX standard
so more C library implementations can run the tests.
2024-08-15 07:11:31 -05:00
David Spickett
6f6422f4a2 [lldb][test] Mark sys_info zdump test unsupported on 32 bit Arm Linux
Until https://github.com/llvm/llvm-project/pull/103056 lands
or another more appropriate check can be found.

This test fails on Ubuntu Focal where zdump is built with 32 bit time_t
but passes on Ubuntu Jammy where zdump is built with 64 bit time_t.

Marking it unsupported means Linaro can upgrade its bots to Ubuntu
Jammy without getting an unexpected pass.
2024-08-15 08:16:05 +00:00
Joseph Huber
9e87061404
[libcxx] Adjust inline assembly constraints for the AMDGPU target (#101747)
Summary:
These assembly constraints are illegal / invalid on the AMDGPU target.
The `r` constraint is only valid on inputs and the `m` constraint isn't
accepted at all. The NVPTX target can handle them because it uses a more
permissive virtual machine (PTX is an IR). Simply add exceptions on the
target to make these work.
2024-08-14 13:42:46 -05:00
Joseph Huber
3b7b2f2efc
[libcxx] Add fallback to standard C when unistd is unavailable (#102005)
Summary:
This utility function gets a temp file to use for tests. It either uses
WIN32 or POSIX to create it. Some targets only follow the C standard,
and this test case will fail. This patch simply adds a fallback that
uses the `tmpnam` function from standard C. This function isn't ideal,
but it is good enough for our use-case.

---------

Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
2024-08-14 13:40:17 -05:00
Louis Dionne
4d08bb11ee
[libc++] Fix ambiguous constructors for std::complex and std::optional (#103409)
Fixes #101960
2024-08-14 14:04:22 -04:00
ZhangYin
812ae91d54
[libc++] <experimental/simd> Add ++/-- operators for simd reference (#88091) 2024-08-14 15:30:17 +08:00
Louis Dionne
29e51f827b
[libc++] Simplify the implementation of LWG2762 (noexcept for unique_ptr) (#102032)
I had originally made some comments in https://reviews.llvm.org/D128214
that were followed when we implemented LWG2762. I don't understand why I
made these comments anymore, but either way it seems like I was wrong
since using `unique_ptr<void>::operator*` should be ill-formed. All
other implementations also make that ill-formed.
2024-08-13 16:18:01 -04:00
Brian Cain
7951673d40
[libc++] Use a different smart ptr type alias (#102089)
The `_SP` type is used by some C libraries and this alias could conflict
with it.
2024-08-12 20:07:08 -05:00
Louis Dionne
b368404dee
[libc++][NFC] Fix typo in count_new.h (#102049)
A function was named alocate_aligned_impl, when it should have been
named allocate_aligned_impl.
2024-08-12 17:04:59 -04:00
Martin Storsjö
a2acea5c38
[libcxx] [test] Mark gdb_pretty_printer_test.sh.cpp as unsupported on Windows (#102891)
In practice, this test hasn't been run by any of the Windows
configurations so far, because it has been excluded by the "UNSUPPORTED:
clang-18, clang-19" line - but it does end up failing if running with
e.g. clang-20 on Windows.

As the test fails on more fundamental issues on Windows, mark it
outright unsupported on this platform; this fixes testing libcxx with a
recent nightly version of Clang from git main.
2024-08-12 23:16:50 +03:00
Xiaoyang Liu
d9caea18f9
[libc++][ranges] LWG3564: transform_view::iterator<true>::value_type and iterator_category should use const F& (#91816)
## Introduction

This patch implements LWG3564:
`transform_view::iterator<true>::value_type` and `iterator_category`
should use `const F&`.

`transform_view`'s iterator currently obtained from a `const
transform_view` invoke the transformation function as `const`, but the
`value_type` and `iterator_category` determination uses non-`const`
`F&`.

## Reference

-
[[range.transform.iterator]](https://eel.is/c++draft/range.transform.iterator)
- [LWG3564](https://cplusplus.github.io/LWG/issue3564)
2024-08-12 19:30:47 +02:00
Nikolas Klauser
5c717d6b1d
[libc++] re-enable clang-tidy in the CI and fix any issues (#102658)
It looks like we've accidentally disabled clang-tidy in the CI. This
re-enables it and fixes the issues accumulated while it was disabled.
2024-08-10 10:08:41 +02:00
Zibi Sarbinowski
f343fee8c5
[libcxx][test][z/OS] Fix hermite.pass.cpp for HEX float (#101019)
The HEX float on z/OS does not have infinity nor NaN. In addition, the
limits are smaller before the overflow occurs in mathematical
calculations. This PR accounts for this.

FYI, this LIT test was recently added in PR
[89982](https://github.com/llvm/llvm-project/pull/89982)
2024-08-07 09:09:06 -04:00
Mark de Wever
4dee6411e0
[libc++] Implements LWG3130. (#101889)
This adds addressof at the required places in [input.output]. Some of
the new tests failed since string used operator& internally. These have
been fixed too.

Note the new fstream tests perform output to a basic_string instead of a
double. Using a double requires num_get specialization

num_get<CharT, istreambuf_iterator<CharT,
char_traits_operator_hijacker<CharT>>

This facet is not present in the locale database so the conversion would
fail due to a missing locale facet. Using basic_string avoids using the
locale.

As a drive-by fixes several bugs in the ofstream.cons tests. These
tested ifstream instead of ofstream with an open mode.

Implements:
- LWG3130 [input.output] needs many addressof

Closes #100246.
2024-08-06 19:47:56 +02:00
Mark de Wever
642259a2f2
[libc++][chrono][test] Fixes bogus loops. (#101890)
Changes the loop range to match similar tests and avoids zero
iterations. The original motivation to reduce the number of iterations
was to allow the test to be executed during constant evaluation.

Fixes: https://github.com/llvm/llvm-project/issues/100502
2024-08-06 19:38:46 +02:00
PaulXiCao
72825fde03
[libc++][math] Fix undue overflowing of std::hypot(x,y,z) (#100820)
This is in relation to mr #93350. It was merged to main, but reverted
because of failing sanitizer builds on PowerPC.

The fix includes replacing the hard-coded threshold constants (e.g.
`__overflow_threshold`) for different floating-point sizes by a general
computation using `std::ldexp`. Thus, it should now work for all architectures.
This has the drawback of not being `constexpr` anymore as `std::ldexp`
is not implemented as `constexpr` (even though the standard mandates it
for C++23).

Closes #92782
2024-08-05 16:08:47 -04:00
Louis Dionne
257831582c
[libc++] Check correctly ref-qualified __is_callable in algorithms (#101553)
We were only checking that the comparator was rvalue callable,
when in reality the algorithms always call comparators as lvalues.
This patch also refactors the tests for callable requirements and
expands it to a few missing algorithms.

This is take 2 of #73451, which was reverted because it broke some
CI bots. The issue was that we checked __is_callable with arguments
in the wrong order inside std::upper_bound. This has now been fixed
and a test was added.

Fixes #69554
2024-08-05 11:23:06 -04:00
Matheus Izvekov
748371183a
[clang] Reland: Instantiate concepts with sugared template arguments (#101782) 2024-08-04 22:11:11 -03:00
Mark de Wever
bfe09685d7
[NFC][libc++][exceptions] Adds tests for LWG3112. (#100881)
The tests kept being based on std::string instead of std::string_view to
allow testing with older C++ dialects.

Adds tests for:
- LWG3112 system_error and filesystem_error constructors taking a string
may not be able to meet their postconditions
2024-08-04 15:49:54 +02:00
Mark de Wever
2fe08ed35a [libc++][test] Adds a TODO.
This addresses the post-commit review comment in
https://github.com/llvm/llvm-project/pull/100775
2024-08-04 12:53:45 +02:00
Mark de Wever
8ab5af6039 [libc++] Fixes an AIX CI failure.
The test now seems to pass so remove the XFAIL.
2024-08-04 12:39:24 +02:00
Nikolas Klauser
0dd8c0ddd0
[libc++] Remove a few includes from <__hash_table> (#99738) 2024-08-04 10:28:53 +02:00
Nikolas Klauser
d07fdf9779
[libc++] Optimize lexicographical_compare (#65279)
If the comparison operation is equivalent to < and that is a total
order, we know that we can use equality comparison on that type instead
to extract some information. Furthermore, if equality comparison on that
type is trivial, the user can't observe that we're calling it. So
instead of using the user-provided total order, we use std::mismatch,
which uses equality comparison (and is vertorized). Additionally, if the
type is trivially lexicographically comparable, we can go one step
further and use std::memcmp directly instead of calling std::mismatch.

Benchmarks:
```
-------------------------------------------------------------------------------------
Benchmark                                                         old             new
-------------------------------------------------------------------------------------
bm_lexicographical_compare<unsigned char>/1                   1.17 ns         2.34 ns
bm_lexicographical_compare<unsigned char>/2                   1.64 ns         2.57 ns
bm_lexicographical_compare<unsigned char>/3                   2.23 ns         2.58 ns
bm_lexicographical_compare<unsigned char>/4                   2.82 ns         2.57 ns
bm_lexicographical_compare<unsigned char>/5                   3.34 ns         2.11 ns
bm_lexicographical_compare<unsigned char>/6                   3.94 ns         2.21 ns
bm_lexicographical_compare<unsigned char>/7                   4.56 ns         2.11 ns
bm_lexicographical_compare<unsigned char>/8                   5.25 ns         2.11 ns
bm_lexicographical_compare<unsigned char>/16                  9.88 ns         2.11 ns
bm_lexicographical_compare<unsigned char>/64                  38.9 ns         2.36 ns
bm_lexicographical_compare<unsigned char>/512                  317 ns         6.54 ns
bm_lexicographical_compare<unsigned char>/4096                2517 ns         41.4 ns
bm_lexicographical_compare<unsigned char>/32768              20052 ns          488 ns
bm_lexicographical_compare<unsigned char>/262144            159579 ns         4409 ns
bm_lexicographical_compare<unsigned char>/1048576           640456 ns        20342 ns
bm_lexicographical_compare<signed char>/1                     1.18 ns         2.37 ns
bm_lexicographical_compare<signed char>/2                     1.65 ns         2.60 ns
bm_lexicographical_compare<signed char>/3                     2.23 ns         2.83 ns
bm_lexicographical_compare<signed char>/4                     2.81 ns         3.06 ns
bm_lexicographical_compare<signed char>/5                     3.35 ns         3.30 ns
bm_lexicographical_compare<signed char>/6                     3.90 ns         3.99 ns
bm_lexicographical_compare<signed char>/7                     4.56 ns         3.78 ns
bm_lexicographical_compare<signed char>/8                     5.20 ns         4.02 ns
bm_lexicographical_compare<signed char>/16                    9.80 ns         6.21 ns
bm_lexicographical_compare<signed char>/64                    39.0 ns         3.16 ns
bm_lexicographical_compare<signed char>/512                    318 ns         7.58 ns
bm_lexicographical_compare<signed char>/4096                  2514 ns         47.4 ns
bm_lexicographical_compare<signed char>/32768                20096 ns          504 ns
bm_lexicographical_compare<signed char>/262144              156617 ns         4146 ns
bm_lexicographical_compare<signed char>/1048576             624265 ns        19810 ns
bm_lexicographical_compare<int>/1                             1.15 ns         2.12 ns
bm_lexicographical_compare<int>/2                             1.60 ns         2.36 ns
bm_lexicographical_compare<int>/3                             2.21 ns         2.59 ns
bm_lexicographical_compare<int>/4                             2.74 ns         2.83 ns
bm_lexicographical_compare<int>/5                             3.26 ns         3.06 ns
bm_lexicographical_compare<int>/6                             3.81 ns         4.53 ns
bm_lexicographical_compare<int>/7                             4.41 ns         4.72 ns
bm_lexicographical_compare<int>/8                             5.08 ns         2.36 ns
bm_lexicographical_compare<int>/16                            9.54 ns         3.08 ns
bm_lexicographical_compare<int>/64                            37.8 ns         4.71 ns
bm_lexicographical_compare<int>/512                            309 ns         24.6 ns
bm_lexicographical_compare<int>/4096                          2422 ns          204 ns
bm_lexicographical_compare<int>/32768                        19362 ns         1947 ns
bm_lexicographical_compare<int>/262144                      155727 ns        19793 ns
bm_lexicographical_compare<int>/1048576                     623614 ns        80180 ns
bm_ranges_lexicographical_compare<unsigned char>/1            1.07 ns         2.35 ns
bm_ranges_lexicographical_compare<unsigned char>/2            1.72 ns         2.13 ns
bm_ranges_lexicographical_compare<unsigned char>/3            2.46 ns         2.12 ns
bm_ranges_lexicographical_compare<unsigned char>/4            3.17 ns         2.12 ns
bm_ranges_lexicographical_compare<unsigned char>/5            3.86 ns         2.12 ns
bm_ranges_lexicographical_compare<unsigned char>/6            4.55 ns         2.12 ns
bm_ranges_lexicographical_compare<unsigned char>/7            5.25 ns         2.12 ns
bm_ranges_lexicographical_compare<unsigned char>/8            5.95 ns         2.13 ns
bm_ranges_lexicographical_compare<unsigned char>/16           11.7 ns         2.13 ns
bm_ranges_lexicographical_compare<unsigned char>/64           45.5 ns         2.36 ns
bm_ranges_lexicographical_compare<unsigned char>/512           366 ns         6.35 ns
bm_ranges_lexicographical_compare<unsigned char>/4096         2886 ns         40.9 ns
bm_ranges_lexicographical_compare<unsigned char>/32768       23054 ns          489 ns
bm_ranges_lexicographical_compare<unsigned char>/262144     185302 ns         4339 ns
bm_ranges_lexicographical_compare<unsigned char>/1048576    741576 ns        19430 ns
bm_ranges_lexicographical_compare<signed char>/1              1.10 ns         2.12 ns
bm_ranges_lexicographical_compare<signed char>/2              1.66 ns         2.35 ns
bm_ranges_lexicographical_compare<signed char>/3              2.23 ns         2.58 ns
bm_ranges_lexicographical_compare<signed char>/4              2.82 ns         2.82 ns
bm_ranges_lexicographical_compare<signed char>/5              3.34 ns         3.06 ns
bm_ranges_lexicographical_compare<signed char>/6              3.92 ns         3.99 ns
bm_ranges_lexicographical_compare<signed char>/7              4.64 ns         4.10 ns
bm_ranges_lexicographical_compare<signed char>/8              5.21 ns         4.61 ns
bm_ranges_lexicographical_compare<signed char>/16             9.79 ns         7.42 ns
bm_ranges_lexicographical_compare<signed char>/64             38.9 ns         2.93 ns
bm_ranges_lexicographical_compare<signed char>/512             317 ns         7.31 ns
bm_ranges_lexicographical_compare<signed char>/4096           2500 ns         47.5 ns
bm_ranges_lexicographical_compare<signed char>/32768         19940 ns          496 ns
bm_ranges_lexicographical_compare<signed char>/262144       159166 ns         4393 ns
bm_ranges_lexicographical_compare<signed char>/1048576      638206 ns        19786 ns
bm_ranges_lexicographical_compare<int>/1                      1.10 ns         2.12 ns
bm_ranges_lexicographical_compare<int>/2                      1.64 ns         3.04 ns
bm_ranges_lexicographical_compare<int>/3                      2.23 ns         2.58 ns
bm_ranges_lexicographical_compare<int>/4                      2.81 ns         2.81 ns
bm_ranges_lexicographical_compare<int>/5                      3.35 ns         3.05 ns
bm_ranges_lexicographical_compare<int>/6                      3.94 ns         4.60 ns
bm_ranges_lexicographical_compare<int>/7                      4.60 ns         4.81 ns
bm_ranges_lexicographical_compare<int>/8                      5.19 ns         2.35 ns
bm_ranges_lexicographical_compare<int>/16                     9.85 ns         2.87 ns
bm_ranges_lexicographical_compare<int>/64                     38.9 ns         4.70 ns
bm_ranges_lexicographical_compare<int>/512                     318 ns         24.5 ns
bm_ranges_lexicographical_compare<int>/4096                   2494 ns          202 ns
bm_ranges_lexicographical_compare<int>/32768                 20000 ns         1939 ns
bm_ranges_lexicographical_compare<int>/262144               160433 ns        19730 ns
bm_ranges_lexicographical_compare<int>/1048576              642636 ns        80760 ns
```
2024-08-04 10:02:43 +02:00
ZhangYin
899055f20b
[libc++] <experimental/simd> Add compound assignment operators for simd reference (#86761) 2024-08-04 10:16:56 +08:00
Mark de Wever
79caa066ea
[libc++][bit] Improves rotate functions. (#98032)
Investigating #96612 shows our implementation was different from the
Standard and could cause UB. Testing the codegen showed quite a bit of
assembly generated for these functions. The functions have been written
differently which allows Clang to optimize the code to use simple CPU
rotate instructions.

Fixes: https://github.com/llvm/llvm-project/issues/96612
2024-08-03 11:19:00 +02:00
Mark de Wever
879640cba0
[libc++] Implements the new version header generator. (#97847)
The generator makes a few changes to the output
- removes the synopsis, it did not really show what was implemented
correctly.
- the output now is clang-format clean.

This code uses the new FTM data structure. Since the contents of this
structure are not up-to-date the code is only used in its tests.
2024-08-03 11:16:29 +02:00
Louis Dionne
451bba6fbf [libc++] Revert "Check correctly ref-qualified __is_callable in algorithms (#73451)"
This reverts commit 8d151f804ff43aaed1edf810bb2a07607b8bba14, which
broke some build bots. I think that is caused by an invalid argument
order when checking __is_comparable in upper_bound.
2024-08-01 15:56:06 -04:00
Nhat Nguyen
8d151f804f
[libc++] Check correctly ref-qualified __is_callable in algorithms (#73451)
We were only checking that the comparator was rvalue callable,
when in reality the algorithms always call comparators as lvalues.
This patch also refactors the tests for callable requirements and
expands it to a few missing algorithms.

Fixes #69554
2024-08-01 14:08:21 -04:00
Mark de Wever
d5a6ec1d4d
[libc++][stringbuf] Test and document LWG2995. (#100879)
As mentioned in the LWG issue libc++ has already implemented the
optimization. This adds tests and documents the implementation defined
behaviour.

Drive-by fixes an initialization.
2024-08-01 11:00:14 -04:00
Damien L-G
59ca618e3b
[libc++] Increase atomic_ref's required alignment for small types (#99654)
This patch increases the alignment requirement for std::atomic_ref
such that we can guarantee lockfree operations more often. Specifically,
we require types that are 1, 2, 4, 8, or 16 bytes in size to be aligned
to at least their size to be used with std::atomic_ref.

This is the case for most types, however a notable exception is
`long long` on x86, which is 8 bytes in length but has an alignment
of 4.

As a result of this patch, one has to be more careful about the
alignment of objects used with std::atomic_ref. Failure to provide
a properly-aligned object to std::atomic_ref is a precondition 
violation and is technically UB. On the flipside, this allows us
to provide an atomic_ref that is actually lockfree more often, 
which is an important QOI property.

More information in the discussion at https://github.com/llvm/llvm-project/pull/99570#issuecomment-2237668661.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-08-01 10:39:27 -04:00