Nikolas Klauser
663f9d189a
[libc++] Refactor __libcpp_is_trivially_equality_comparable to be a variable template ( #173151 )
2025-12-22 10:04:47 +01:00
Nikolas Klauser
3ea59fa19b
[libc++] Remove zero size branch from memmove ( #155419 )
...
This can significantly reduce the generated code, since it avoids a
branch the optimizer has to see through. At least with our benchmarks
there isn't a significant change in performance. There might be a bit of
an improvement, but it's inconclusive IMO:
```
--------------------------------------------------------------------------------------------
Benchmark old new
--------------------------------------------------------------------------------------------
BM_StringFindNoMatch/10 1.48 ns 1.46 ns
BM_StringFindNoMatch/64 2.30 ns 2.19 ns
BM_StringFindNoMatch/512 9.80 ns 9.62 ns
BM_StringFindNoMatch/4096 76.3 ns 74.0 ns
BM_StringFindNoMatch/32768 509 ns 496 ns
BM_StringFindNoMatch/131072 2038 ns 1998 ns
BM_StringFindAllMatch/1 3.51 ns 3.16 ns
BM_StringFindAllMatch/8 3.09 ns 2.87 ns
BM_StringFindAllMatch/64 3.25 ns 2.97 ns
BM_StringFindAllMatch/512 11.7 ns 10.6 ns
BM_StringFindAllMatch/4096 83.6 ns 85.0 ns
BM_StringFindAllMatch/32768 566 ns 583 ns
BM_StringFindAllMatch/131072 2327 ns 2312 ns
BM_StringFindMatch1/1 1001 ns 981 ns
BM_StringFindMatch1/8 1002 ns 980 ns
BM_StringFindMatch1/64 1004 ns 981 ns
BM_StringFindMatch1/512 1012 ns 989 ns
BM_StringFindMatch1/4096 1088 ns 1058 ns
BM_StringFindMatch1/32768 1637 ns 1577 ns
BM_StringFindMatch2/1 1006 ns 984 ns
BM_StringFindMatch2/8 1007 ns 988 ns
BM_StringFindMatch2/64 1005 ns 989 ns
BM_StringFindMatch2/512 1015 ns 996 ns
BM_StringFindMatch2/4096 1087 ns 1067 ns
BM_StringFindMatch2/32768 1612 ns 1593 ns
BM_StringCtorDefault 0.373 ns 0.340 ns
BM_StringConstructDestroyCStr_Empty_Opaque 1.84 ns 2.66 ns
BM_StringConstructDestroyCStr_Empty_Transparent 0.456 ns 0.248 ns
BM_StringConstructDestroyCStr_Small_Opaque 3.13 ns 2.80 ns
BM_StringConstructDestroyCStr_Small_Transparent 0.388 ns 0.388 ns
BM_StringConstructDestroyCStr_Large_Opaque 18.1 ns 17.9 ns
BM_StringConstructDestroyCStr_Large_Transparent 12.5 ns 12.1 ns
BM_StringConstructDestroyCStr_Huge_Opaque 155 ns 151 ns
BM_StringConstructDestroyCStr_Huge_Transparent 61.6 ns 61.3 ns
BM_StringAssignStr_Empty_Opaque 0.729 ns 0.719 ns
BM_StringAssignStr_Empty_Transparent 0.555 ns 0.532 ns
BM_StringAssignStr_Small_Opaque 0.766 ns 0.754 ns
BM_StringAssignStr_Small_Transparent 0.539 ns 0.531 ns
BM_StringAssignStr_Large_Opaque 11.4 ns 11.6 ns
BM_StringAssignStr_Large_Transparent 11.6 ns 11.9 ns
BM_StringAssignStr_Huge_Opaque 248 ns 242 ns
BM_StringAssignStr_Huge_Transparent 247 ns 243 ns
BM_StringAssignAsciiz_Empty_Opaque 2.82 ns 3.50 ns
BM_StringAssignAsciiz_Empty_Transparent 0.375 ns 0.369 ns
BM_StringAssignAsciiz_Small_Opaque 3.81 ns 3.54 ns
BM_StringAssignAsciiz_Small_Transparent 0.488 ns 0.487 ns
BM_StringAssignAsciiz_Large_Opaque 13.9 ns 13.5 ns
BM_StringAssignAsciiz_Large_Transparent 13.7 ns 13.5 ns
BM_StringAssignAsciiz_Huge_Opaque 298 ns 291 ns
BM_StringAssignAsciiz_Huge_Transparent 289 ns 282 ns
BM_StringAssignAsciizMix_Opaque 6.25 ns 5.90 ns
BM_StringAssignAsciizMix_Transparent 3.50 ns 3.55 ns
BM_StringCopy_Empty 0.649 ns 0.632 ns
BM_StringCopy_Small 0.658 ns 0.633 ns
BM_StringCopy_Large 8.14 ns 8.00 ns
BM_StringCopy_Huge 109 ns 112 ns
BM_StringMove_Empty 1.31 ns 1.28 ns
BM_StringMove_Small 1.31 ns 1.28 ns
BM_StringMove_Large 1.31 ns 1.28 ns
BM_StringMove_Huge 1.31 ns 1.28 ns
BM_StringDestroy_Empty 0.854 ns 0.739 ns
BM_StringDestroy_Small 0.863 ns 0.742 ns
BM_StringDestroy_Large 9.62 ns 9.62 ns
BM_StringDestroy_Huge 15.3 ns 15.0 ns
BM_StringEraseToEnd_Empty_Opaque 1.05 ns 1.04 ns
BM_StringEraseToEnd_Empty_Transparent 0.377 ns 0.373 ns
BM_StringEraseToEnd_Small_Opaque 1.04 ns 1.03 ns
BM_StringEraseToEnd_Small_Transparent 0.458 ns 0.451 ns
BM_StringEraseToEnd_Large_Opaque 1.26 ns 1.22 ns
BM_StringEraseToEnd_Large_Transparent 1.04 ns 1.00 ns
BM_StringEraseToEnd_Huge_Opaque 1.36 ns 1.36 ns
BM_StringEraseToEnd_Huge_Transparent 1.14 ns 1.14 ns
BM_StringEraseWithMove_Empty_Opaque 1.33 ns 1.31 ns
BM_StringEraseWithMove_Empty_Transparent 1.05 ns 1.03 ns
BM_StringEraseWithMove_Small_Opaque 3.35 ns 3.33 ns
BM_StringEraseWithMove_Small_Transparent 3.75 ns 3.51 ns
BM_StringEraseWithMove_Large_Opaque 3.15 ns 3.17 ns
BM_StringEraseWithMove_Large_Transparent 2.94 ns 2.96 ns
BM_StringEraseWithMove_Huge_Opaque 42.4 ns 41.9 ns
BM_StringEraseWithMove_Huge_Transparent 39.2 ns 39.0 ns
BM_StringRelational_Eq_Empty_Empty_Control 2.35 ns 2.13 ns
BM_StringRelational_Eq_Empty_Small_Control 0.511 ns 0.516 ns
BM_StringRelational_Eq_Empty_Large_Control 0.516 ns 0.504 ns
BM_StringRelational_Eq_Empty_Huge_Control 0.500 ns 0.499 ns
BM_StringRelational_Eq_Small_Small_Control 2.43 ns 2.47 ns
BM_StringRelational_Eq_Small_Small_ChangeFirst 1.78 ns 1.89 ns
BM_StringRelational_Eq_Small_Small_ChangeMiddle 1.98 ns 1.84 ns
BM_StringRelational_Eq_Small_Small_ChangeLast 2.64 ns 2.54 ns
BM_StringRelational_Eq_Small_Large_Control 0.502 ns 0.502 ns
BM_StringRelational_Eq_Small_Huge_Control 0.513 ns 0.509 ns
BM_StringRelational_Eq_Large_Large_Control 2.19 ns 2.17 ns
BM_StringRelational_Eq_Large_Large_ChangeFirst 1.66 ns 1.74 ns
BM_StringRelational_Eq_Large_Large_ChangeMiddle 1.86 ns 1.87 ns
BM_StringRelational_Eq_Large_Large_ChangeLast 2.14 ns 2.13 ns
BM_StringRelational_Eq_Large_Huge_Control 0.510 ns 0.514 ns
BM_StringRelational_Eq_Huge_Huge_Control 101 ns 101 ns
BM_StringRelational_Eq_Huge_Huge_ChangeFirst 1.73 ns 1.67 ns
BM_StringRelational_Eq_Huge_Huge_ChangeMiddle 58.3 ns 57.5 ns
BM_StringRelational_Eq_Huge_Huge_ChangeLast 102 ns 102 ns
BM_StringRelational_Less_Empty_Empty_Control 2.42 ns 2.16 ns
BM_StringRelational_Less_Empty_Small_Control 2.20 ns 2.09 ns
BM_StringRelational_Less_Empty_Large_Control 2.43 ns 2.10 ns
BM_StringRelational_Less_Empty_Huge_Control 2.43 ns 2.07 ns
BM_StringRelational_Less_Small_Empty_Control 2.42 ns 2.20 ns
BM_StringRelational_Less_Small_Small_Control 2.36 ns 2.35 ns
BM_StringRelational_Less_Small_Small_ChangeFirst 1.73 ns 1.73 ns
BM_StringRelational_Less_Small_Small_ChangeMiddle 1.73 ns 1.73 ns
BM_StringRelational_Less_Small_Small_ChangeLast 2.47 ns 2.46 ns
BM_StringRelational_Less_Small_Large_Control 2.39 ns 2.33 ns
BM_StringRelational_Less_Small_Huge_Control 2.23 ns 2.34 ns
BM_StringRelational_Less_Large_Empty_Control 2.16 ns 2.12 ns
BM_StringRelational_Less_Large_Small_Control 2.33 ns 2.40 ns
BM_StringRelational_Less_Large_Large_Control 2.37 ns 2.29 ns
BM_StringRelational_Less_Large_Large_ChangeFirst 1.49 ns 1.49 ns
BM_StringRelational_Less_Large_Large_ChangeMiddle 1.74 ns 1.74 ns
BM_StringRelational_Less_Large_Large_ChangeLast 2.03 ns 2.11 ns
BM_StringRelational_Less_Large_Huge_Control 2.21 ns 2.20 ns
BM_StringRelational_Less_Huge_Empty_Control 2.27 ns 2.15 ns
BM_StringRelational_Less_Huge_Small_Control 2.32 ns 2.43 ns
BM_StringRelational_Less_Huge_Large_Control 2.24 ns 2.16 ns
BM_StringRelational_Less_Huge_Huge_Control 101 ns 98.6 ns
BM_StringRelational_Less_Huge_Huge_ChangeFirst 1.49 ns 1.49 ns
BM_StringRelational_Less_Huge_Huge_ChangeMiddle 57.1 ns 58.8 ns
BM_StringRelational_Less_Huge_Huge_ChangeLast 102 ns 102 ns
BM_StringRelational_Compare_Empty_Empty_Control 2.16 ns 1.91 ns
BM_StringRelational_Compare_Empty_Small_Control 1.80 ns 1.85 ns
BM_StringRelational_Compare_Empty_Large_Control 1.81 ns 2.15 ns
BM_StringRelational_Compare_Empty_Huge_Control 1.96 ns 1.82 ns
BM_StringRelational_Compare_Small_Empty_Control 2.14 ns 1.86 ns
BM_StringRelational_Compare_Small_Small_Control 1.98 ns 1.98 ns
BM_StringRelational_Compare_Small_Small_ChangeFirst 1.73 ns 1.73 ns
BM_StringRelational_Compare_Small_Small_ChangeMiddle 1.73 ns 1.73 ns
BM_StringRelational_Compare_Small_Small_ChangeLast 2.24 ns 2.44 ns
BM_StringRelational_Compare_Small_Large_Control 1.98 ns 1.98 ns
BM_StringRelational_Compare_Small_Huge_Control 2.23 ns 1.98 ns
BM_StringRelational_Compare_Large_Empty_Control 2.14 ns 2.05 ns
BM_StringRelational_Compare_Large_Small_Control 2.23 ns 2.04 ns
BM_StringRelational_Compare_Large_Large_Control 2.12 ns 1.95 ns
BM_StringRelational_Compare_Large_Large_ChangeFirst 1.41 ns 1.49 ns
BM_StringRelational_Compare_Large_Large_ChangeMiddle 1.74 ns 1.74 ns
BM_StringRelational_Compare_Large_Large_ChangeLast 2.24 ns 2.04 ns
BM_StringRelational_Compare_Large_Huge_Control 2.13 ns 2.12 ns
BM_StringRelational_Compare_Huge_Empty_Control 1.85 ns 2.16 ns
BM_StringRelational_Compare_Huge_Small_Control 2.23 ns 2.22 ns
BM_StringRelational_Compare_Huge_Large_Control 2.08 ns 2.15 ns
BM_StringRelational_Compare_Huge_Huge_Control 98.3 ns 101 ns
BM_StringRelational_Compare_Huge_Huge_ChangeFirst 1.36 ns 1.49 ns
BM_StringRelational_Compare_Huge_Huge_ChangeMiddle 57.6 ns 58.0 ns
BM_StringRelational_Compare_Huge_Huge_ChangeLast 102 ns 111 ns
BM_StringRelationalLiteral_Eq_Empty_Empty_Control 0.356 ns 0.351 ns
BM_StringRelationalLiteral_Eq_Empty_Empty_ChangeFirst 0.321 ns 0.319 ns
BM_StringRelationalLiteral_Eq_Empty_Empty_ChangeMiddle 0.321 ns 0.319 ns
BM_StringRelationalLiteral_Eq_Empty_Empty_ChangeLast 0.322 ns 0.319 ns
BM_StringRelationalLiteral_Eq_Empty_Small_Control 0.651 ns 0.634 ns
BM_StringRelationalLiteral_Eq_Empty_Large_Control 0.472 ns 0.464 ns
BM_StringRelationalLiteral_Eq_Small_Empty_Control 0.389 ns 0.358 ns
BM_StringRelationalLiteral_Eq_Small_Small_Control 0.604 ns 0.723 ns
BM_StringRelationalLiteral_Eq_Small_Small_ChangeFirst 0.696 ns 0.696 ns
BM_StringRelationalLiteral_Eq_Small_Small_ChangeMiddle 0.673 ns 0.598 ns
BM_StringRelationalLiteral_Eq_Small_Small_ChangeLast 0.735 ns 0.690 ns
BM_StringRelationalLiteral_Eq_Small_Large_Control 0.469 ns 0.465 ns
BM_StringRelationalLiteral_Eq_Large_Empty_Control 0.841 ns 0.858 ns
BM_StringRelationalLiteral_Eq_Large_Small_Control 0.628 ns 0.613 ns
BM_StringRelationalLiteral_Eq_Large_Large_Control 0.917 ns 0.911 ns
BM_StringRelationalLiteral_Eq_Large_Large_ChangeFirst 0.915 ns 0.903 ns
BM_StringRelationalLiteral_Eq_Large_Large_ChangeMiddle 0.909 ns 0.911 ns
BM_StringRelationalLiteral_Eq_Large_Large_ChangeLast 0.914 ns 0.911 ns
BM_StringRelationalLiteral_Less_Empty_Empty_Control 0.457 ns 0.226 ns
BM_StringRelationalLiteral_Less_Empty_Empty_ChangeFirst 0.456 ns 0.226 ns
BM_StringRelationalLiteral_Less_Empty_Empty_ChangeMiddle 0.455 ns 0.225 ns
BM_StringRelationalLiteral_Less_Empty_Empty_ChangeLast 0.454 ns 0.224 ns
BM_StringRelationalLiteral_Less_Empty_Small_Control 2.15 ns 2.13 ns
BM_StringRelationalLiteral_Less_Empty_Large_Control 2.05 ns 2.11 ns
BM_StringRelationalLiteral_Less_Small_Empty_Control 0.228 ns 0.225 ns
BM_StringRelationalLiteral_Less_Small_Small_Control 2.46 ns 2.20 ns
BM_StringRelationalLiteral_Less_Small_Small_ChangeFirst 1.98 ns 1.88 ns
BM_StringRelationalLiteral_Less_Small_Small_ChangeMiddle 1.98 ns 1.86 ns
BM_StringRelationalLiteral_Less_Small_Small_ChangeLast 2.68 ns 2.53 ns
BM_StringRelationalLiteral_Less_Small_Large_Control 2.44 ns 2.34 ns
BM_StringRelationalLiteral_Less_Large_Empty_Control 0.228 ns 0.225 ns
BM_StringRelationalLiteral_Less_Large_Small_Control 2.36 ns 2.32 ns
BM_StringRelationalLiteral_Less_Large_Large_Control 2.21 ns 2.26 ns
BM_StringRelationalLiteral_Less_Large_Large_ChangeFirst 1.65 ns 1.69 ns
BM_StringRelationalLiteral_Less_Large_Large_ChangeMiddle 1.89 ns 1.89 ns
BM_StringRelationalLiteral_Less_Large_Large_ChangeLast 2.06 ns 1.98 ns
BM_StringRelationalLiteral_Compare_Empty_Empty_Control 0.396 ns 0.394 ns
BM_StringRelationalLiteral_Compare_Empty_Empty_ChangeFirst 0.399 ns 0.398 ns
BM_StringRelationalLiteral_Compare_Empty_Empty_ChangeMiddle 0.389 ns 0.394 ns
BM_StringRelationalLiteral_Compare_Empty_Empty_ChangeLast 0.397 ns 0.396 ns
BM_StringRelationalLiteral_Compare_Empty_Small_Control 1.87 ns 1.85 ns
BM_StringRelationalLiteral_Compare_Empty_Large_Control 1.83 ns 1.77 ns
BM_StringRelationalLiteral_Compare_Small_Empty_Control 0.396 ns 0.391 ns
BM_StringRelationalLiteral_Compare_Small_Small_Control 1.98 ns 1.98 ns
BM_StringRelationalLiteral_Compare_Small_Small_ChangeFirst 1.49 ns 1.48 ns
BM_StringRelationalLiteral_Compare_Small_Small_ChangeMiddle 1.48 ns 1.48 ns
BM_StringRelationalLiteral_Compare_Small_Small_ChangeLast 2.23 ns 2.19 ns
BM_StringRelationalLiteral_Compare_Small_Large_Control 1.98 ns 1.97 ns
BM_StringRelationalLiteral_Compare_Large_Empty_Control 0.391 ns 0.391 ns
BM_StringRelationalLiteral_Compare_Large_Small_Control 1.98 ns 1.97 ns
BM_StringRelationalLiteral_Compare_Large_Large_Control 1.89 ns 1.91 ns
BM_StringRelationalLiteral_Compare_Large_Large_ChangeFirst 1.49 ns 1.24 ns
BM_StringRelationalLiteral_Compare_Large_Large_ChangeMiddle 1.58 ns 1.68 ns
BM_StringRelationalLiteral_Compare_Large_Large_ChangeLast 1.93 ns 1.78 ns
BM_StringRead_Hot_Shallow_Empty 0.497 ns 0.496 ns
BM_StringRead_Hot_Shallow_Small 0.498 ns 0.500 ns
BM_StringRead_Hot_Shallow_Large 0.501 ns 0.742 ns
BM_StringRead_Hot_Deep_Empty 0.496 ns 0.503 ns
BM_StringRead_Hot_Deep_Small 0.497 ns 0.498 ns
BM_StringRead_Hot_Deep_Large 0.743 ns 0.976 ns
BM_StringRead_Cold_Shallow_Empty 1.32 ns 1.35 ns
BM_StringRead_Cold_Shallow_Small 1.35 ns 1.38 ns
BM_StringRead_Cold_Shallow_Large 2.03 ns 2.07 ns
BM_StringRead_Cold_Deep_Empty 1.40 ns 1.40 ns
BM_StringRead_Cold_Deep_Small 1.40 ns 1.41 ns
BM_StringRead_Cold_Deep_Large 2.16 ns 2.25 ns
```
2025-08-27 15:59:01 +02:00
Mark de Wever
da618cf0a7
[NFC][libc++] Guard against operator& hijacking. ( #128351 )
...
This set usage of operator& instead of std::addressof seems not be easy
to "abuse". Some seem easy to misuse, like basic_ostream::operator<<,
trying to do that results in compilation errors since the `widen`
function is not specialized for the hijacking character type. Hence
there are no tests.
2025-02-27 17:47:34 +01:00
Nikolas Klauser
d8148244e9
[libc++] Decrease instantiation cost of __constexpr_memmove ( #125109 )
...
Using `if constexpr` in `__constexpr_memmove` makes the instantiation
three times faster for the same type, since it avoids a bunch of class
instantiations and SFINAE for constexpr support that's never actually
used. Given that `__constexpr_memmove` is used quite a bit through
`std::copy` and is instantiated multiple times when just including
`<__string/char_traits.h>` this can provide a nice compile time speedup
for a very simple change.
2025-02-04 17:12:35 +01:00
Louis Dionne
cedb44af53
[libc++] Pass type information down to __libcpp_allocate ( #118837 )
...
Currently, places where we call __libcpp_allocate must drop type
information on the ground even when they actually have such information
available. That is unfortunate since some toolchains and system
allocators are able to provide improved security when they know what
type is being allocated.
This is the purpose of http://wg21.link/p2719 , where we introduce a new
variant of `operator new` which takes a type in its interface. A
different but related issue is that `std::allocator` does not honor any
in-class `T::operator new` since it is specified to call the global
`::operator new` instead.
This patch closes the gap to make it trivial for implementations that
provide typed memory allocators to actually benefit from that
information in more contexts, and also makes libc++ forward-compatible
with future proposals that would fix the existing defects in
`std::allocator`. It also makes the internal allocation API higher level
by operating on objects instead of operating on bytes of memory.
Since this is a widely-used function and making this a template could
have an impact on debug info sizes, I tried minimizing the number of
templated layers by removing `__do_deallocate_handle_size`, which was
easy to replace with a macro (and IMO this leads to cleaner code).
2025-01-13 09:10:36 -05:00
Nikolas Klauser
e99c4906e4
[libc++] Granularize <cstddef> includes ( #108696 )
2024-10-31 02:20:10 +01:00
Nikolas Klauser
ba87515fea
[libc++][RFC] Always define internal feature test macros ( #89178 )
...
Currently, the library-internal feature test macros are only defined if
the feature is not available, and always have the prefix
`_LIBCPP_HAS_NO_`. This patch changes that, so that they are always
defined and have the prefix `_LIBCPP_HAS_` instead. This changes the
canonical use of these macros to `#if _LIBCPP_HAS_FEATURE`, which means
that using an undefined macro (e.g. due to a missing include) is
diagnosed now. While this is rather unlikely currently, a similar change
in `<__configuration/availability.h>` caught a few bugs. This also
improves readability, since it removes the double-negation of `#ifndef
_LIBCPP_HAS_NO_FEATURE`.
The current patch only touches the macros defined in `<__config>`. If
people are happy with this approach, I'll make a follow-up PR to also
change the macros defined in `<__config_site>`.
2024-10-12 09:49:52 +02:00
Louis Dionne
d6832a611a
[libc++][modules] Modularize <cstddef> ( #107254 )
...
Many headers include `<cstddef>` just for size_t, and pulling in
additional content (e.g. the traits used for std::byte) is unnecessary.
To solve this problem, this patch splits up `<cstddef>` into
subcomponents so that headers can include only the parts that they
actually require.
This has the added benefit of making the modules build a lot stricter
with respect to IWYU, and also providing a canonical location where we
define `std::size_t` and friends (which were previously defined in
multiple headers like `<cstddef>` and `<ctime>`).
After this patch, there's still many places in the codebase where we
include `<cstddef>` when `<__cstddef/size_t.h>` would be sufficient.
This patch focuses on removing `<cstddef>` includes from __type_traits
to make these headers non-circular with `<cstddef>`. Additional
refactorings can be tackled separately.
2024-09-05 08:28:33 -04: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
Nikolas Klauser
cb7a03b41f
[libc++] Fix failures with GCC 14 ( #92663 )
...
Fixes #91831
2024-06-01 12:20:41 +02:00
Nikolas Klauser
d30f6bc5cd
[libc++][NFC] Refactor __libcpp_datasizeof to be a variable template ( #87769 )
...
This decreases memory consumption and compiles times slightly and
removes a bit of boilderplate.
2024-04-29 11:21:28 +02:00
Nikolas Klauser
29312d39ff
[libc++] Optimize char_traits a bit ( #72799 )
...
This implements two kinds of optimizations. Specifically
- `char_traits<char8_t>` uses `char` code paths; these are heavily
optimized and the operations are equivalent
- `char16_t` and `char32_t` `find` uses `std::find` to forward to
`wmemchr` if they have the same size
2024-04-20 11:40:18 +02:00
Louis Dionne
6f36ead577
[libc++] Fix std::move algorithm with trivial move-only types
...
As reported in https://reviews.llvm.org/D151953#4472195 , the std::move
algorithm (and various other functions that relied on it) stopped working
after starting to use `__constexpr_memmove` in its implementation. This
patch fixes the underlying issue in `__constexpr_memmove` and adds tests
for various related algorithms and functions that were not exercising
trivial move-only types.
Differential Revision: https://reviews.llvm.org/D154613
2023-07-10 11:50:09 -04:00
Nikolas Klauser
c4e98722ca
[libc++] Fix std::copy and std::move for ranges with potentially overlapping tail padding
...
This fixes thr bug reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108846 .
Reviewed By: ldionne, #libc
Spies: mstorsjo, libcxx-commits
Differential Revision: https://reviews.llvm.org/D151953
2023-06-30 13:48:16 -07:00
Nikolas Klauser
355f466744
[libc++][NFC] Add __element_count and use it in the constexpr C functions
...
This makes it less ambiguous what the parameter is meant to get.
Reviewed By: #libc, ldionne
Spies: ldionne, libcxx-commits
Differential Revision: https://reviews.llvm.org/D152040
2023-06-05 15:08:01 -07:00
Nikolas Klauser
1fd08edd58
[libc++] Forward to std::{,w}memchr in std::find
...
Reviewed By: #libc, ldionne
Spies: Mordante, libcxx-commits, ldionne, mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D144394
2023-05-25 07:59:50 -07:00
Nikolas Klauser
746cf7e38c
[libc++] Use the __is_trivially_equality_comparable builtin
...
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D148553
2023-05-07 18:38:08 -07:00
Nikolas Klauser
380b6a13da
[libc++][NFC] rename __is_trivially_equality_comparable to __libcpp_is_trivially_equality_comparable
...
This is required for D147175.
Reviewed By: ldionne, Mordante, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D147953
2023-04-12 14:31:16 +02:00
Nikolas Klauser
b4ecfd3c46
[libc++] Forward to std::memcmp for trivially comparable types in equal
...
Reviewed By: #libc, ldionne
Spies: ldionne, Mordante, libcxx-commits
Differential Revision: https://reviews.llvm.org/D139554
2023-02-21 17:11:21 +01:00
Nikolas Klauser
e8cb3559ee
[libc++] Move constexpr <cstring> functions into their own headers and remove unused <cstring> includes
...
Reviewed By: ldionne, Mordante, #libc, #libc_abi
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D143329
2023-02-21 16:56:29 +01:00