Commit Graph

9013 Commits

Author SHA1 Message Date
Yuanfang Chen 81b51b61f8 Fix libcxx build after cd0a5889d7 2022-04-12 15:42:56 -07:00
Louis Dionne 0cc34ca7ec [libc++] Define legacy symbols for inline functions at a finer-grained level
When we build the library with the stable ABI, we need to include some
functions in the dylib that were made inline in later versions of the
library (to avoid breaking code that might be relying on those symbols).

However, those methods were made non-inline whenever we'd be building
the library, which means that all translation units would end up using
the old out-of-line definition of these methods, as opposed to the new
inlined version. This patch makes it so that only the translation units
that actually define the out-of-line methods use the old definition,
opening up potential optimization opportunities in other translation
units.

This should solve some of the issues encountered in D65667.

Differential Revision: https://reviews.llvm.org/D123519
2022-04-12 13:44:30 -04:00
Mark de Wever 7738db2c06 [NFC][libc++][test] Move time tests.
In the C++20 Standard time is no longer section under utilities, but
became its own chapter. This moves the time tests accordingly so their
location matches the current Standard.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122745
2022-04-12 17:49:48 +02:00
Louis Dionne 8b5e4c038e [runtimes][CI] Add a 20 minutes individual test time out
If a single test has been running for more than 20 minutes on a CI node,
something is wrong and it should time-out instead of running until the
node potentially times out itself.

Differential Revision: https://reviews.llvm.org/D114896
2022-04-11 17:47:05 -04:00
zijunzhao 2d0475e371 [libcxx] locale_bionic.h: skip ndk-version.h on Android platform
The Android platform does not have ndk-version.h, but it will always
have up-to-date libc headers, so it does not need any compatibility
code intended for past versions of NDK_MAJOR. If ndk-version.h is missing,
assume NDK_MAJOR is (conceptually) infinite

Bug: https://buganizer.corp.google.com/issues/222341313
Test: None
2022-04-11 17:51:12 +00:00
Martin Storsjö 64e4dd329c [libcxx] [test] Fix back-to-back use of get_temp_file_name() on Windows
On non-Windows platforms, get_temp_file_name() uses `mkstemp()`,
which picks a unique name and creates a file atomically. The
Windows implementation uses `_mktemp_s()`, which doesn't create the
file. The documentation of `_mktemp_s()` also says that by design,
the function uses the same pattern within a process, as long as that
file doesn't exist.

Thus previously, two consecutive calls to `get_temp_file_name()`
on Windows returned the same file name.

Try to create the suggested temp file with `_O_EXCL` (marking the
file name as already used for future calls to `_mktemp_s`) and retry
if we weren't able to exclusively create the file.

This fixes the test failures on Windows observed in D122257.

Differential Revision: https://reviews.llvm.org/D122612
2022-04-11 19:46:40 +03:00
Louis Dionne b9ca1e5a5a [libc++][NFC] Use noexcept instead of _NOEXCEPT for code compiled into the library
We build the library with C++20 anyways, so we can use noexcept directly.
2022-04-11 12:30:38 -04:00
Louis Dionne c292b6066c [libc++] Implement P1007R3: std::assume_aligned
This supersedes and incoroporates content from both D108906 and D54966,
and also some original content.

Co-Authored-by: Marshall Clow <mclow.lists@gmail.com>
Co-Authored-by: Gonzalo Brito Gadeschi

Differential Revision: https://reviews.llvm.org/D118938
2022-04-11 10:46:52 -04:00
Louis Dionne 2c6217f252 [libc++] Make .version.pass.cpp tests be compile-only tests
We don't really need to run them.
2022-04-11 10:40:04 -04:00
Nikolas Klauser 732920d847 [libc++] Remove the usage of __init in operator+
`operator+` currently calls `__init`. This patch removes the usage of implementation details.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123058
2022-04-11 15:59:52 +02:00
Nikolas Klauser aed0e8b805 [libc++] Rename the template arguments of the algorithm result types
Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123463
2022-04-10 14:22:13 +02:00
Nikolas Klauser a96443edde [libc++] Implement P0401R6 (allocate_at_least)
Reviewed By: ldionne, var-const, #libc

Spies: mgorny, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D122877
2022-04-09 16:03:45 +02:00
Mark de Wever fb9a692be5 [libc++][format][4/6] Improve formatted_size.
Use a specialized "buffer" to count the number of insertions instead of
using a `string` as storage type.

Depends on D110497.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D110498
2022-04-09 09:36:29 +02:00
Mark de Wever 889302292b [libc++][format][3/6] Adds a __container_buffer.
Instead of writing every character directly into the container by using
a `back_insert_iterator` the data is buffered in an `array`. This buffer
is then inserted to the container by calling its `insert` member function.

Since there's no guarantee every container's `insert` behaves properly
containers need to opt-in to this behaviour. The appropriate standard
containers opt-in to this behaviour.

This change improves the performance of the format functions that use a
`back_insert_iterator`.

Depends on D110495

Reviewed By: ldionne, vitaut, #libc

Differential Revision: https://reviews.llvm.org/D110497
2022-04-09 09:35:48 +02:00
Louis Dionne 72cd50b6fd [libc++] Add missing 'return 0;' to main() in test 2022-04-08 17:10:58 -04:00
Nilay Vaish f950ba004b [libcxx][NFC] Format sort.h
This is to simplify the changes made in D122780.  This diff was generated using the command:

```
clang-format include/__algorithm/sort.h  -i
```

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D122858
2022-04-08 17:05:02 -04:00
Gustavo Henrique Nihei 4fe6a5d69a [libc++] Rename PS() macro to avoid clashing with Xtensa register name
This patch addresses a clash with the PS register from Xtensa
defined in the <specreg.h> header file, which is commonly included in
OS implementation.

Issue identified while building libc++ port for Apache NuttX, targeting
Xtensa-based chips (e.g. Espressif's ESP32).

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

Differential Revision: https://reviews.llvm.org/D122479
2022-04-08 17:00:29 -04:00
Azat Khuzhin c3d0205ee7 [libc++] Avoid using anonymous struct with base classes (fixes GCC 12)
GCC 12 reports:

     libcxx/include/string:727:13: error: anonymous struct with base classes
     727 |             : __padding<value_type>

Differential Revision: https://reviews.llvm.org/D122598
2022-04-08 16:14:44 -04:00
Mark de Wever d49c0ba5ab [libc++][test] Use the Japanese locale.
This change is done to see whether all platforms have a CI with the
Japanese locale installed.

This wires in the locale in the tests and uses it in one test. This is
a preparation for the tests of the chrono formatters.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122738
2022-04-08 20:00:34 +02:00
Mark de Wever 476047bf8e [libc++] Adds back_insert_iterator::__get_container.
Adds a `__get_container` member as suggested by @Quuxplusone in D110497.

Includes  s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/.

Reviewed By: Quuxplusone, #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110573
2022-04-08 17:13:50 +02:00
Mark de Wever 7277b00a29 [NFC][libc++][format] Prepare unit tests.
Before implementing P2216's format-string adjust the unit tests.
After P2216 the format* functions require a compile-time string literal.
This changes prepares the tests.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D122534
2022-04-08 17:11:45 +02:00
Nikolas Klauser 08920cc043 [libc++] Add __is_callable type trait and begin granularizing type_traits
`__is_callable` is required to ensure that the classic algorithms are only called with functions or functors. I also begin to granularize `<type_traits>`.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D123114
2022-04-08 12:23:52 +02:00
Nikolas Klauser 628fcfd520 [libc++] Add tests for std::string default constructor and destructor
Reviewed By: ldionne, var-const, #libc, nilayvaish

Spies: nilayvaish, libcxx-commits

Differential Revision: https://reviews.llvm.org/D123129
2022-04-08 12:21:43 +02:00
Marco Gelmi 194d1965d2 Introduce branchless sorting functions for sort3, sort4 and sort5.
We are introducing branchless variants for sort3, sort4 and sort5.
These sorting functions have been generated using Reinforcement
Learning and aim to replace __sort3, __sort4 and __sort5 variants
for integral types.

The libc++ benchmarks were run on isolated machines for Skylake, ARM and
AMD architectures and achieve statistically significant improvement in
sorting random integers on test cases from sort1 to sort262144 for
uint32 and uint64.

A full performance overview for Intel Skylake, AMD and Arm can be
found here: https://bit.ly/3AtesYf

Reviewed By: ldionne, #libc, philnik

Spies: daniel.mankowitz, mgrang, Quuxplusone, andreamichi, philnik, libcxx-commits, nilayvaish, kristof.beyls

Differential Revision: https://reviews.llvm.org/D118029
2022-04-08 09:00:30 +02:00
Mark de Wever b05027aaf9 Revert "[libc++][format] Use a helper constant."
This reverts commit 82427685ea.

This seems to break the AIX-32 bit build.
2022-04-07 22:40:08 +02:00
Mark de Wever 82427685ea [libc++][format] Use a helper constant.
The code accidentally uses a hard-coded value. Use a constant to make
sure the same value is used at both places.
2022-04-07 19:25:13 +02:00
Arthur Eubanks 0a77e63322 [libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT
Introduce _LIBCPP_ASSERTIONS_DISABLE_ASSUME which makes _LIBCPP_ASSERT
not call __builtin_assume when _LIBCPP_ENABLE_ASSERTIONS == 0.

Calling __builtin_assume was introduced in D122397.

__builtin_assume is generally supposed to improve optimizations, but can
cause regressions when LLVM has trouble handling the calls to
`llvm.assume()` (see comments in D122397).

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D123175
2022-04-07 09:00:31 -07:00
Louis Dionne b7042b73a3 [libc++] Add back-deployment testing on arm64 macs
Differential Revision: https://reviews.llvm.org/D123081
2022-04-07 10:15:40 -04:00
Nikolas Klauser 1306b1025c [libc++][ranges] Implement ranges::count{, _if}
Reviewed By: var-const, Mordante, ldionne, #libc

Spies: tcanens, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D121523
2022-04-07 15:18:14 +02:00
Nikolas Klauser 1b9c5f60aa [libc++] Remove redundant __invoke_constexpr functions
There are `constexpr` versions for the different `__invoke` functions, which seem to be identical other than begin `constexpr` since C++11 instead of being `constexpr` since C++20.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123003
2022-04-07 13:56:11 +02:00
Nikolas Klauser cd7b444078 [libc++][ranges] Add implicit conversion to bool test for ranges::find{, if, if_not}
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D122011
2022-04-07 12:03:43 +02:00
Martin Storsjö 7594e23679 [libcxx] [test] Stop defining LIBCXX-WINDOWS-FIXME
There are no such markings left - all of them have been fixed or
analyzed.

This closes llvm.org/PR32730 (github issue #32077).

Differential Revision: https://reviews.llvm.org/D123145
2022-04-06 22:54:39 +03:00
Mark de Wever 3fb3770983 [libc++] Use cpp20_output_iterator in tests.
Adds the new cpp20_output_iterator in the ranges::transform test.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D123139
2022-04-06 17:48:27 +02:00
Mark de Wever d78624975b [NFC][libc++] Modularize chrono's calendar.
The is a followup of D116965 to split the calendar header. This is a
preparation to add the formatters for the chrono header.

The code is only moved no other changes have been made.

Reviewed By: ldionne, #libc, philnik

Differential Revision: https://reviews.llvm.org/D122995
2022-04-06 17:47:53 +02:00
Louis Dionne e27a122b3a [libc++] Support arrays in make_shared and allocate_shared (P0674R1)
This patch implements P0674R1, i.e. support for arrays in std::make_shared
and std::allocate_shared.

Co-authored-by: Zoe Carver <z.zoelec2@gmail.com>

Differential Revision: https://reviews.llvm.org/D62641
2022-04-06 08:42:55 -04:00
Martin Storsjö 586182ae4e [libcxx] [test] Remove UNSUPPORTED markings for mingw issues that no longer are present in CI
Differential Revision: https://reviews.llvm.org/D123146
2022-04-06 10:03:10 +03:00
Louis Dionne 6720bc202a [libc++] Remove error about _LIBCPP_ALTERNATE_STRING_LAYOUT not being supported anymore
It's been over two years since I added the temporary error, so I think
it's reasonable to remove it now.
2022-04-05 19:45:21 -04:00
Louis Dionne fd92ca00b4 [libc++][NFC] Remove stray whitespace in comment 2022-04-05 19:45:20 -04:00
Martin Storsjö 6efda5e6d6 [libcxx] [test] Fix the locale ctype widen tests on Windows
On Windows, like on macOS and FreeBSD, widening char(-5) in the
"C" locale succeeds and produces L'\u00fb'.

Switch widen_many to test \xfb instead of \x85; the mingw
version of btowc widens \x85 in the "C" locale into
\u2026 (which is the corresponding character according to the
Windows-1252 codepage), while Microsoft CRT's btowc widens it
into \u0085 (just like macOS and FreeBSD). Switch this to test \xfb
which is the character tested by the widen_1 test (as `char(-5)`),
which gets handled the same by all Windows implementations of btowc.

Differential Revision: https://reviews.llvm.org/D121003
2022-04-05 20:06:44 +03:00
Hui Xie c00df57b86 [libc++] add global variable template std::views::empty
[libc++] add global variable template std::views::empty
Note it is neither a range adaptor, nor a CPO. It is simplify a global variable template.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D122996
2022-04-05 18:18:16 +02:00
Mark de Wever 83de107382 [libc++][test] Adds an cpp20_output_iterator.
This iterator is used to test code that only needs to satisfy the
output_iterator concept. Follow-up changes will use this iterator in
older language Standards.

Reviewed By: ldionne, #libc, philnik, var-const

Differential Revision: https://reviews.llvm.org/D122072
2022-04-05 17:31:42 +02:00
Louis Dionne 8ec4999766 [libc++] Tidy up tests for deduction guides and other compile-time failing properties in std::string
Instead of using `.fail.cpp` tests, use `.verify.cpp` to check for the
exact reason of the failure. In the case of deduction guides, use SFINAE
based tests instead since that is our preferred way of testing those.

Finally, ensure that we actually run the test in `iter_alloc_deduction.pass.cpp`,
since we were not running anything before.

Differential Revision: https://reviews.llvm.org/D123055
2022-04-05 10:52:52 -04:00
Louis Dionne 45ce3f3252 [libc++] Silence new deprecation warnings for C functions in tests 2022-04-05 10:26:32 -04:00
Nikolas Klauser 3ba8548c8e [libc++][ranges] Implement ranges::transform
Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D122173
2022-04-05 11:06:28 +02:00
Louis Dionne 9a44ed43cf [libc++] Implement tests for private headers using the new generator
Differential Revision: https://reviews.llvm.org/D123028
2022-04-04 17:44:47 -04:00
Martin Storsjö dba90d74be [libcxx] Stop recommending setting LIBCXX_HAS_WIN32_THREAD_API in the MinGW builds
Since a8d15a9266 / D110975, this is
the default, even if winpthread headers are available, so we don't
need to cargo cult setting this option in all builds.

Differential Revision: https://reviews.llvm.org/D122717
2022-04-04 23:07:40 +03:00
Louis Dionne 13796495ec [libc++] Fix std::is_array<T[0]> and add tests
Differential Revision: https://reviews.llvm.org/D122810
2022-04-04 13:55:18 -04:00
Louis Dionne a4f73b9b14 [libc++][NFC] Rename generate_assertion_tests.py to generate_header_tests.py 2022-04-04 09:10:52 -04:00
Louis Dionne be1294de9d [libc++] Implement all public header tests using the new generator
Note that `generate_assertion_tests.py` will be renamed to
`generate_header_tests.py` separately to facilitate change tracking.

Differential Revision: https://reviews.llvm.org/D123000
2022-04-04 09:09:37 -04:00
Louis Dionne e70533ae6c [libc++] Remove unused <iosfwd> include from <__debug>
Differential Revision: https://reviews.llvm.org/D122999
2022-04-03 16:15:48 -04:00