Commit Graph

6540 Commits

Author SHA1 Message Date
Martijn Vels 2bad222680 Add optimization to basic_string::assign for compile-time known constant values.
Summary:
This change optimizes the assign() methods for string where either the contents or lengths are compile time known constants. For small strings (< min_cap) we can execute the assignment entirely inline. For strings up to 128 bytes we allow the compiler to efficiently inline the copy operation after we call the offline __resize<>() method. Short / long branches are taken at the call site for better branch prediction and allowing FDO optimizations.

Benchmarks (unstable / google perflab):
```
name                                                old time/op             new time/op             delta
BM_StringAssignAsciiz_Empty_Opaque                  5.69ns ± 7%             5.97ns ± 7%     ~             (p=0.056 n=5+5)
BM_StringAssignAsciiz_Empty_Transparent             5.39ns ± 7%             0.79ns ± 8%  -85.36%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Small_Opaque                  11.2ns ± 5%             11.0ns ± 6%     ~             (p=0.548 n=5+5)
BM_StringAssignAsciiz_Small_Transparent             10.1ns ± 7%              1.0ns ± 8%  -89.76%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Large_Opaque                  23.5ns ± 7%             23.8ns ± 7%     ~             (p=0.841 n=5+5)
BM_StringAssignAsciiz_Large_Transparent             21.4ns ± 7%             12.7ns ± 7%  -40.83%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Huge_Opaque                    336ns ± 4%              327ns ± 7%     ~             (p=0.421 n=5+5)
BM_StringAssignAsciiz_Huge_Transparent               331ns ± 5%              324ns ± 7%     ~             (p=0.548 n=5+5)
BM_StringAssignAsciizMix_Opaque                     13.6ns ±10%             13.7ns ± 9%     ~             (p=0.690 n=5+5)
BM_StringAssignAsciizMix_Transparent                12.9ns ± 8%              3.6ns ± 8%  -71.82%          (p=0.008 n=5+5)
```

Reviewers: EricWF, #libc!

Subscribers: jfb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D82221
2020-06-29 14:34:34 -04:00
Louis Dionne 5d83880885 [runtimes] Remove the ability to select the old libc++ testing format
As announced on libcxx-dev at [1], the old libc++ testing format is being
removed in favour of the new one. Follow-up commits will clean up the
code that is dead after the removal of this option.

[1]: http://lists.llvm.org/pipermail/libcxx-dev/2020-June/000885.html
2020-06-29 14:07:41 -04:00
Louis Dionne da940b1a2d [libc++] Enable tests and documentation by default when building standalone
Since we can always find the rest of the LLVM tree, we can always run the
tests in the standalone mode. Do it so that the default behavior is the
same in the standalone and non-standalone modes.
2020-06-29 12:40:07 -04:00
Louis Dionne 09943e8de1 [libc++] Provide a default LLVM_PATH when building standalone
Since we require that libc++ is built as part of the monorepo layout, we
can assume the path of the rest of LLVM and avoid requiring that LLVM_PATH
be set explicitly.
2020-06-29 12:40:07 -04:00
Louis Dionne eb68a0ab5e [libc++] Do not try creating llvm-lit when LIBCXX_INCLUDE_TESTS is OFF in the standalone build
Doing so doesn't work reliably, since it relies on LLVM_* implementation
detail variables being set. Furthermore, since we rely on the lit.site.cfg
being generated, running the tests requires LIBCXX_INCLUDE_TESTS=ON anyway.
2020-06-29 11:55:02 -04:00
Louis Dionne 8bc62db272 [libc++] Remove support for building through llvm-config
We've decided to move away from that by requiring that libc++ is built
as part of the monorepo a while ago. This commit removes code pertaining
to that unsupported use case and produces a clear error when the user
violates that.

In fact, building outside of the monorepo will still work as long as
LLVM_PATH is pointing to the root of the LLVM project, although that
is not officially supported.
2020-06-26 15:13:04 -04:00
Louis Dionne 05c552ad05 [libc++] Fix the runtimes build after making __config_site mandatory
The runtimes build includes libcxx/include/CMakeLists.txt directly instead
of going through the top-level CMake file. This not-very-hygienic inclusion
caused some variables like LIBCXX_BINARY_DIR not to be defined properly,
and the config_site generation logic to fail after landing 53623d4aa7.

This patch works around this issue by defining the missing variables.
However, the proper fix for this would be for the runtimes build to
always go through libc++'s top-level CMakeLists.txt. Doing otherwise
is unsupported.
2020-06-26 01:26:34 -04:00
Louis Dionne 53623d4aa7 [libc++] Always generate a __config_site header
Before this patch, the __config_site header was only generated when at
least one __config_site macro needed to be defined. This lead to two
different code paths in how libc++ is configured, depending on whether
a __config_site header was generated or not. After this patch, the
__config_site is always generated, but it can be empty in case there
are no macros to define in it.

More context on why this change is important
--------------------------------------------
In addition to being confusing, this double-code-path situation lead to
broken code being checked in undetected in 2405bd6898, which introduced
the LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT CMake setting. Specifically,
the _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT <__config_site> macro was
supposed NOT to be defined unless LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
was specified explicitly on the CMake command line. Instead, what happened
is that it was defined to 0 if it wasn't specified explicitly and a
<__config_site> header was generated. And defining that macro to 0 had
the important effect of using the non-unique RTTI comparison implementation,
which changes the ABI.

This change in behavior wasn't noticed because the <__config_site> header
is not generated by default. However, the Apple configuration does cause
a <__config_site> header to be generated, which lead to the wrong RTTI
implementation being used, and to https://llvm.org/PR45549. We came close
to an ABI break in the dylib, but were saved due to a downstream-only
change that overrode the decision of the <__config_site> for the purpose
of RTTI comparisons in libc++abi. This is an incredible luck that we should
not rely on ever again.

While the problem itself was fixed with 2464d8135e by setting
LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT explicitly in the Apple
CMake cache and then in d0fcdcd28f by making the setting less
brittle, the point still is that we should have had a single code
path from the beginning. Unlike most normal libraries, the macros
that configure libc++ are really complex, there's a lot of them and
they control important properties of the C++ runtime. There must be
a single code path for that, and it must be simple and robust.

Differential Revision: https://reviews.llvm.org/D80927
2020-06-26 00:47:48 -04:00
Louis Dionne 8808574e74 [libc++] Add missing <stddef.h> include to <wchar.h>
It is needed because <wchar.h> uses size_t.
2020-06-25 19:27:32 -04:00
Louis Dionne 7014b44c0a [libc++] Remove unnecessary LLVM_INCLUDE_BENCHMARKS option in the Apple build
Since we're using an empty top-level CMakeLists.txt instead of the CMakeLists.txt
inside llvm/, we don't need to specify LLVM_INCLUDE_BENCHMARKS anymore.
2020-06-25 17:34:45 -04:00
Louis Dionne 06be4bb5e6 [libc++] Remove deprecated _LIBCPP_ALTERNATE_STRING_LAYOUT macro
We use the _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT macro for that now instead.
I did leave a check behind to make sure that nobody was still using the old
macro name. I'll remove it a couple of months down the road.
2020-06-25 16:33:30 -04:00
Arthur O'Dwyer d8e3e55857 [libc++] Fix some typos in the comment header for <regex>
No functional change because all the changed "code" is actually inside
comments.

Differential Revision: https://reviews.llvm.org/D82589
2020-06-25 15:34:51 -04:00
Louis Dionne 33c9c10d18 [libc++abi] Allow specifying custom Lit config files
This is the libc++abi counterpart of 0c66af970c.
2020-06-25 12:15:15 -04:00
Xun Li f2dd08844c [Coroutines] Fix a few failing tests
Summary:
https://reviews.llvm.org/D82029 introduced the non-throw check for final_suspend(). There are a few tests I missed in that patch.
Fixing them here.

Reviewers: #libc, lewissbaker, modocache, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, modocache, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D82338
2020-06-23 10:48:17 -07:00
David Zarzycki f3f016dbaa [libcxx tests] Clang is more strict now about coroutines
As of 516803dc86, clang is now more
strictly enforcing the coroutine specification.

See: https://reviews.llvm.org/D82029
2020-06-23 06:51:35 -04:00
Eric Christopher 76ff0775d8 [libcxx] As part of using inclusive language within the llvm
project, migrate away from the use of blacklist and whitelist.
2020-06-19 21:37:11 -07:00
Raul Tambre 98eb1457ff [libc++] Require concepts support for <numbers>
Similar to <concepts>, we need to protect the header and test against
inclusion and being run if concepts aren't supported by the compiler.

Differential Revision: https://reviews.llvm.org/D82171
2020-06-19 10:49:44 -04:00
Raul Tambre 4f6c4b473c [libc++] Implement <numbers>
Summary: Constants have 33 significant decimal digits for IEEE 754 128-bit floating-point numbers.

Reviewers: ldionne, #libc, EricWF, zoecarver, curdeius

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D77505
2020-06-19 14:25:02 +05:30
Louis Dionne 4976771e11 [libc++] Add a dummy CMake file to include runtime subprojects
Add a simple CMakeLists.txt to build the runtimes in lockstep without
building all of LLVM. See [1] for details.

[1]: http://lists.llvm.org/pipermail/llvm-dev/2020-June/142384.html
2020-06-18 14:34:56 -04:00
Martijn Vels d96aac4354 Optimize 'construct at end' loops in vector
Summary:
This change adds local 'end' and 'pos' variables for the main loop inmstead of using the ConstructTransaction variables directly.

We observed that not all vector initialization and resize operations got properly vectorized, i.e., (partially) unrolled into XMM stores for floats.

For example, `vector<int32_t> v(n, 1)` gets vectorized, but `vector<float> v(n, 1)`. It looks like the compiler assumes the state is leaked / aliased in the latter case (unclear how/why for float, but not for int32), and because of this fails to see vectorization optimization?

See https://gcc.godbolt.org/z/UWhiie

By using a local `__new_end_` (fixed), and local `__pos` (copied into __tx.__pos_ per iteration), we offer the compiler a clean loop for unrolling.

A demonstration can be seen in the isolated logic in https://gcc.godbolt.org/z/KoCNWv

The com

Reviewers: EricWF, #libc!

Subscribers: libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D82111
2020-06-18 13:51:12 -04:00
Alex Richardson 7142fef03d [libc++] Don't override LIBCXX_CXX_ABI_INCLUDE_PATHS for libcxxrt
When testing libc++ for our cross-compiled CheriBSD target we specify an
explicit LIBCXX_CXX_ABI_INCLUDE_PATHS for libcxxrt. The hardcoded path
/usr/include/c++/v1 was introduced in 61e89737c5
and overrides any value passed on the CMake command line. Fix this by using
it as a fallback rather than a fixed default value.

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D82095
2020-06-18 18:09:22 +01:00
Christopher Di Bella ec789a41e2 [libc++] Add equality for spaceship types for themselves
- Adds operator==(partial_ordering, partial_ordering)
- Adds operator==(weak_ordering, weak_ordering)
- Adds operator==(strong_ordering, strong_ordering)

Differential Revision: https://reviews.llvm.org/D81823
2020-06-18 10:22:50 -04:00
Michael Park 8fbd6d99a0
[libcxx/variant] Fix build error for when exceptions disabled.
Reviewers: #libc!

Subscribers: libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D81973
2020-06-18 07:21:42 -07:00
Louis Dionne 0c66af970c [libc++] Allow specifying custom Lit config files
Before this patch, the libc++ test suite first loads lit.site.cfg
(generated by CMake), and then lit.cfg. It's also possible to load
lit.cfg before lit.site.cfg and to point to a custom lit.site.cfg
file using '--param=libcxx_site_config'. However, in that case, lit.cfg
still relies on the site configuration filling up the 'config' object
like the default lit.site.cfg file does, which isn't flexible enough.

This commit simplifies the setup by having just a single Lit site config
file per CMake configuration, and always loading exactly that config file.
However, the config file to use can be selected when setting up CMake via
the LIBCXX_TEST_CONFIG setting. Furthermore, the site configs are entirely
standalone, which means that a new site config can be added that doesn't
need to conform what's expected by config.py.

Differential Revision: https://reviews.llvm.org/D81846
2020-06-18 10:06:04 -04:00
Michael Park ada2a8ea4a
Remove the try/catch codepath if `swap` is `noexcept`.
Summary:
In the case where `swap` is `noexcept`, we should avoid the extension to provide strong-exception guarantee.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46342

Reviewers: #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, mclow.lists, miscco, ldionne, zoecarver, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D81954
2020-06-16 14:51:22 -07:00
Louis Dionne 12b01ab7fa [libc++] Don't trigger unsigned conversion warnings in std::advance
The Standard documents the signature of std::advance as

    template <class Iter, class Distance>
    constexpr void advance(Iter& i, Distance n);

Furthermore, it does not appear to put any restriction on what the type
of Distance should be. While it is understood that it should usually
be std::iterator_traits::difference_type, I couldn't find any wording
that mandates that. Similarly, I couldn't find wording that forces the
distance to be a signed type.

This patch changes std::advance to accept any type in the second argument,
which appears to be what the Standard mandates. We then coerce it to the
iterator's difference type, but that's an implementation detail.

Differential Revision: https://reviews.llvm.org/D81425
2020-06-16 13:47:47 -04:00
Louis Dionne c8d0aaa7ff [libc++] Automatically create the %T directory inside config tests 2020-06-15 19:32:06 -04:00
Louis Dionne 619beb0a53 [libc++] Replace the FakeLitConfig by an actual LitConfig object 2020-06-15 19:32:06 -04:00
Louis Dionne eeb96e4f19 [libc++] Re-apply parts of 3ea9450bda "Migrate Lit platform detection to the DSL"
The commit was reverted in 43c4afb56f because it broke the Windows to
Linux cross-compilation build bots. The issue turned out to be that the
bots were setting the LIBCXX_EXECUTOR incorrectly. This has been fixed
now and verified with the bot owners.

Note that this is only a partial re-application of the commit, since
non-problematic parts of the commits have already been re-applied earlier.
2020-06-15 17:40:04 -04:00
Louis Dionne 96e48e9a61 [libc++] Add the ability to run arbitrary programs using the DSL
This is useful for checking runtime properties of the target system.
This is a partial re-application of 3ea9450bda. This part was tested
to work on a Windows host with a SSH executor.
2020-06-15 14:59:53 -04:00
Louis Dionne 58610eb368 [libc++] Raise an exception if a Lit feature resolves to an invalid name
This allows reporting issues early when creating feature names.
2020-06-15 12:20:50 -04:00
Vladimir Vereschaka 43c4afb56f Revert "[libc++] Migrate Lit platform detection to the DSL"
This reverts commit 3ea9450bda.

The commit fails the remote library tests on the toolchain builders:

http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64
2020-06-13 12:50:43 -07:00
Casey Carter 8b828e9838 [libcxx][test] Silence MSVC signed-to-unsigned implicit conversion warnings 2020-06-12 14:54:51 -07:00
Louis Dionne 9c2c698fd4 [libc++] Add missing sitedir to local Lit config
It relied on the site dir being added by a previous config file.
2020-06-12 14:58:54 -04:00
Casey Carter 6ffa6a300d [libcxx][test] include <algorithm> for is_permutation 2020-06-12 11:54:03 -07:00
Louis Dionne a9b9f797e2 [libc++] Remove obsolete 'newlib' Lit Feature
The feature isn't defined anywhere, so it's effectively dead.
2020-06-12 14:08:18 -04:00
Louis Dionne 3ea9450bda [libc++] Migrate Lit platform detection to the DSL
As an important fly-by fix, also make sure we set those features to their
value on the target we run on, not on the host compiling the test suite.
2020-06-12 13:59:45 -04:00
Louis Dionne db8255aee7 [libc++] Parse commands inside _executeScriptInternal to remove duplication
Instead of parsing the command each time prior to calling _executeScriptInternal,
do it once inside _executeScriptInternal.
2020-06-12 12:03:15 -04:00
Louis Dionne c8c7bb31f2 [libc++] Remove redundant UNSUPPORTED annotation for the GDB pretty-printer tests
That test is already only enabled if LIBCXX_TEST_GDB_PRETTY_PRINTERS is
enabled, which isn't the default. If someone turns on that option on
Windows, they should be able to run the test and see whatever failure
happens.
2020-06-12 10:57:11 -04:00
Louis Dionne f998e0d679 [libc++] Make executor scripts executable
This allows running the scripts directly, without running them through
Python.
2020-06-12 10:29:04 -04:00
Louis Dionne 96e6cbbf94 [libc++] Allow specifying arbitrary custom executors with the new format
The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.

This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.

Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR="<path-to-ssh.py> --host <host>". Similarly, arbitrary
scripts can be provided.
2020-06-11 16:24:29 -04:00
Louis Dionne 1fc5010d6b [libc++] Consider everything inside %T to be a dependency of each test
Instead of passing file dependencies individually, assume that the
whole content of the unique test directory is a dependency. This
simplifies the test harness significantly, by making %T the directory
that contains everything required to run a test. This also removes the
need for the %{file_dependencies} substitution, which is removed by this
patch.

Furthermore, this patch also changes the harness to execute tests locally
inside %T, so as to avoid creating a separate directory for no purpose.
2020-06-10 22:38:05 -04:00
Casey Carter 24836f8cd0 [libcxx][test] MSVC's __is_trivially_copyable is fixed in VS 16.7
... so we can disable `TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE`.
2020-06-10 13:55:33 -07:00
Louis Dionne 4e813bbdf3 [libc++] Make sure tests are run in a unique directory
This will allow simplifying executors by always just copying the whole
%T, and assuming that all file dependencies are contained in it.

Superseeds https://reviews.llvm.org/D78245, which tried to make %T unique
in Lit, but which encountered push back.
2020-06-10 16:19:10 -04:00
Joel E. Denny d9a42ec98a [libc++] Work around gcc/Power9 bug in `include/thread`
This fixes PR39696, which breaks the libcxx build with gcc (I tested
7.5.0) on Power9.  This fix was suggested at

https://bugs.llvm.org/show_bug.cgi?id=39696#c38

but never applied.  It just reverts 0583d9ea8d, which reverses
components of the original fix in 3bf63cf3b3, which is correct.

Fixes https://llvm.org/PR39696

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D81438
2020-06-10 12:40:43 -04:00
Louis Dionne 756db3084b [libc++] Install locales in the build bot Docker images
This allows running the locale tests on the build bots.
2020-06-10 09:37:14 -04:00
Mikhail Maltsev 4e94bdceb0 [libcxx] Fix std::vector construct_iter_iter.pass.cpp test (C++98/03)
The test is failing on 32-bit targets in C++03 mode. Clang produces
the following warning: 'integer literal is too large to be represented
in type 'long' and is subject to undefined behavior under C++98,
interpreting as 'unsigned long'; this literal will have type 'long
long' in C++11 onwards [-Wc++11-compat]' which is promoted to an error
and causes the test to fail.

There have been no changes in the test itself since 2019, so it looks
like the diagnostic has been updated.

Differential Revision: https://reviews.llvm.org/D81559
2020-06-10 14:27:33 +01:00
Louis Dionne a2439bebe1 [libc++] Translate the enable_filesystem parameter to the DSL 2020-06-10 08:54:42 -04:00
Louis Dionne 01a0c3b49a [libc++] Define the no-exceptions Lit feature using the DSL
Instead of using logic in config.py, use the DSL to grab the no-exceptions
user-configurable parameter from the Lit command-line invocation.
2020-06-10 08:03:51 -04:00
Louis Dionne 78e266efab [libc++] Allow picking Lit parameters from the config
Unlike parameters in litConfig.params, the config isn't shared across
all test suites. For example, if we want to enable exceptions in the
tests for libcxxabi, but not in the tests for libcxx, we can't set the
enable_exceptions parameter in the litConfig object, cause it will be
used by both. Instead, setting it inside the config object solves that
problem.
2020-06-10 08:02:07 -04:00
Louis Dionne d9dec697cb [libc++][CMake] Add CMake caches for commonly supported configurations
This commit adds CMake caches for the various configurations of libc++
that are tested by our build bots.

Differential Revision: https://reviews.llvm.org/D81293
2020-06-09 14:52:14 -04:00
Louis Dionne 7fb40e1569 [libc++] Fix too stringent availability markup for bad_optional_access
The availability markup for bad_optional_access marked it as being added
in MacOS 10.14 and aligned releases, however it appears to have been added
in Mac OS 10.13 and aligned releases.
2020-06-09 14:39:51 -04:00
Louis Dionne 1f48f8f6e2 [libc++] Avoid UB in year_month_day_last::day() for incorrect months
This effectively implements the resolution of LWG3231, which mandates
that calling year_month_day_last::day() on an invalid year_month_day_last
is unspecified behavior. Before this change, it was undefined behavior.

Differential Revision: https://reviews.llvm.org/D81477
2020-06-09 13:43:13 -04:00
Louis Dionne babd3aefc9 [libc++] Remove workarounds for the lack of clock_gettime on older macOS platforms
This increases the Mac OS requirement for building libc++ to 10.12.
Note that it doesn't change whether the *headers* still support older
platforms -- it's only that macOS >= 10.12 is required to build the
dylib from sources.

Differential Revision: https://reviews.llvm.org/D74489
2020-06-09 12:57:03 -04:00
Louis Dionne cb347a1106 [libc++] Remove assertion in year_month_day_last::day()
This reverts commit 0c148430cf, which added an assertion in day().
The Standard doesn't allow day() to crash -- instead it says that the
result is unspecified.

Differential Revision: https://reviews.llvm.org/D70346
2020-06-09 10:46:13 -04:00
Louis Dionne 60cde7bbb7 [libc++] Improve tests for iterators.operations
Reduce duplication between the constexpr and the non-constexpr test cases,
and add tests for the return type of the various operations.
2020-06-08 14:59:35 -04:00
zoecarver b1b64dbef1 [NFC] [libcxx] Remove shared_ptr's no-rvalue unique_ptr converting constructor.
All compilers supported by libc++ have rvalues in C++03 mode so, there is no need for this non-rvalue overload.

Differential Revision: https://reviews.llvm.org/D80881
2020-06-08 09:49:21 -07:00
Louis Dionne 339156ad63 [libc++] Avoid passing -xc++ in Lit feature detection
Otherwise, if %{flags} contain other files like static libraries, those
files are treated as C++ source files instead of object files, and the
compiler gets all confused.
2020-06-05 13:41:48 -04:00
Louis Dionne 3864ee7722 [libc++] Translate locale detection to the DSL 2020-06-05 09:50:00 -04:00
Louis Dionne e0184357fc [libc++] Link against libatomic when it is found
Before this patch, we tried detecting whether small atomics were available
without linking against libatomic. However, that's not really what we want
to know -- instead, we want to know what's required in order to support
atomics fully, which is to link against libatomic when it's provided.

That is both much simpler, and it doesn't suffer the problem that we would
not link against libatomic when small atomics didn't require it, which
lead to non-lockfree atomics never working.

Furthermore, because we understand that some platforms might not want to
(or be able to) ship non-lockfree atomics, we add that notion to the test
suite, independently of a potential extern library.

After this patch, we therefore:
(1) Link against libatomic when it is provided
(2) Independently detect whether non-lockfree atomics are supported in
    the test suite, regardless of whether that means we're linking against
    an external library or not (which is an implementation detail).

Differential Revision: https://reviews.llvm.org/D81190
2020-06-05 09:28:44 -04:00
Louis Dionne cc78f1e0fe [libc++] Avoid warning for large types with std::atomic in the test suite
It is legitimate for the test suite to use types that are slow to use
with std::atomic, since we need coverage for those too. If we don't
disable the warning, it is promoted to an error, which prevents us
from testing such types.
2020-06-04 14:06:04 -04:00
Louis Dionne 68e4e8a8d0 [libc++] Disable LLVM benchmarks in the Apple build 2020-06-04 12:03:25 -04:00
Louis Dionne b68bf11efc [libc++] Merge the Apple install-libcxx and libcxxabi scripts
Also, refactor the now-merged script to remove code duplication in the
creation of universal dylibs.
2020-06-04 11:20:03 -04:00
Louis Dionne 39a116ee07 [libc++] Move away from the standalone build for Apple libc++ and libc++abi 2020-06-04 10:19:38 -04:00
Louis Dionne 2bbfa6b02b [libc++] Fix test broken in C++03 due to requiring C++11 features from vector 2020-06-03 12:59:17 -04:00
Louis Dionne 62cfa3a0b5 [libc++] Support move construction and assignment in <thread> in C++03
Libc++ provides support for <thread> in C++03 as an extension. Furthermore,
it does not support any compiler that doesn't have rvalue references. It
is hence possible to provide the move constructor and move assignment
operator in C++03.
2020-06-03 12:16:27 -04:00
David Zarzycki e25f01be0c [libcxx testing] Fix bot failure in my last commit 2020-06-03 11:28:14 -04:00
David Zarzycki 6ce71d2dad [libcxx testing] Fix more bogus timeouts: condvarany/notify_all.pass.cpp
On slow/busy machines, timing cannot be guaranteed.
2020-06-03 10:28:12 -04:00
Louis Dionne 31cbe0f240 [libc++] Remove the c++98 Lit feature from the test suite
C++98 and C++03 are effectively aliases as far as Clang is concerned.
As such, allowing both std=c++98 and std=c++03 as Lit parameters is
just slightly confusing, but provides no value. It's similar to allowing
both std=c++17 and std=c++1z, which we don't do.

This was discovered because we had an internal bot that ran the test
suite under both c++98 AND c++03 -- one of which is redundant.

Differential Revision: https://reviews.llvm.org/D80926
2020-06-03 09:37:22 -04:00
David Zarzycki 579d6ed48c [libcxx testing] Fix lingering bugs in notify_one.pass.cpp
This test is arguably fatally flawed, at least as long as C++ condition
variables are just trivial wrappers around POSIX. I've added some notes
to the test for future authors to consider.
2020-06-03 08:50:27 -04:00
Olivier Giroux 06aaf0b343 Updated synopsis of <atomic> to match what is implemented 2020-06-01 14:30:13 -07:00
Louis Dionne 23776a178f [libc++] Add assertions on OOB accesses in std::array when the debug mode is enabled
Like we do for empty std::array, make sure we have assertions in place
for obvious out-of-bounds issues in std::array when the debug mode is
enabled (which isn't by default).
2020-06-01 16:37:39 -04:00
Louis Dionne 66a14d151e [libc++] NFC: Minor refactoring in std::array 2020-06-01 16:28:44 -04:00
David Zarzycki 1c4238e7a0 [libcxx testing] Stop using arbitrary timeouts in one test
On a busy and/or slow system, 100ms might not be long enough. Instead,
we now use atomic variables to communicate between threads.
2020-05-30 06:09:11 -04:00
Louis Dionne 7265ff928a [libc++] Fix issues with the triviality of std::array
The Standard is currently unimplementable. We have to pick between:

1. Not implementing constexpr support properly in std::array<T, 0>
2. Making std::array<T, 0> non-trivial even when T is trivial
3. Returning nullptr from std::array<T, 0>::begin()

Libc++ initially picked (1). In 77b9abfc8e, we started implementing constexpr properly, but lost the guarantee of triviality. Since it seems like both (1) and (2) are really important, it seems like (3) is the only viable option for libc++, after all. This is also what other implementations are doing.

This patch moves libc++ from (1) to (3).

It also:
- Improves the test coverage for the various ways of initializing std::array
- Adds tests for the triviality of std::array
- Adds tests for the aggregate-ness of std::array

Reviewed By: #libc, miscco, EricWF, zoecarver

Differential Revision: https://reviews.llvm.org/D80821
2020-05-29 16:32:55 -07:00
Louis Dionne d0fcdcd28f [libc++] Fix the LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT setting
When the __config_site header is generated, but LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
wasn't specified, _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT would be defined
to 0, which was the NonUnique RTTI comparison implementation. The intent
was to use the Unique RTTI comparison implementation in that case, which
caused https://llvm.org/PR45549.

Instead, use a proper "switch" to select the RTTI comparison implementation.
Note that 0 can't be used as a value, because that is treated the same
by CMake as a variable that is just not defined.

Differential Revision: https://reviews.llvm.org/D80037
2020-05-29 06:14:30 -04:00
Louis Dionne ebddf90a4e [libc++] NFC: Remove outdated numbering in <bit> synopsis 2020-05-28 14:31:21 -04:00
Louis Dionne 77b9abfc8e [libc++] Complete overhaul of constexpr support in std::array
This commit adds missing support for constexpr in std::array under all
standard modes up to and including C++20. It also transforms the <array>
tests to check for constexpr-friendliness under the right standard modes.

Fixes https://llvm.org/PR40124
Fixes rdar://57522096
Supersedes https://reviews.llvm.org/D60666

Differential Revision: https://reviews.llvm.org/D80452
2020-05-28 12:31:06 -04:00
Louis Dionne f46bb9dd5c [NFC] Reformat TEST_FOO macros in test_macros.h
To make them easier to read and to make it easier to add new ones.
2020-05-27 16:54:43 -04:00
Marek Kurdej d1dbda10ce [libc++] [LWG3201] Update status page: lerp should be marked noexcept.
Summary: Update status page and test synopsis. Add synopsis in <cmath>.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D80456
2020-05-25 22:28:21 +02:00
zoecarver 37ef15143a [libcxx] Fix C++14 and up constexpr members in MoveOnly.
Summary: a4b8ee6 made all MoveOnly members constexpr but, some members and constructors contain expressions that are only valid in C++14 and later. This patch prefixes those methods and constructors with TEST_CONSTEXPR_CXX14.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80482
2020-05-25 11:38:24 -07:00
Sergej Jaskiewicz b62ce9e05d Re-commit "[libc++] [test] Generate static_test_env on the fly"
Don't use std::filesystem APIs for CWDGuard, use POSIX functions
instead. This way the tests don't rely on the correctness of
the functionality they're testing.

Differential Revision: https://reviews.llvm.org/D78200
2020-05-25 19:13:16 +03:00
zoecarver 6e48a6e407 [libcxx] Fix deprecation warning by suppressing deprecated around
__test_has_construct.

In C++17 some tests started failing after a521532aa1. This fixes those errors by suppressing the deprecation warning when calling `construct` in `__test_has_construct`. This is the same solution as `__has_destroy_test` already uses.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80481
2020-05-23 14:33:10 -07:00
zoecarver a521532aa1 [NFC] Remove non-variadic overloads of allocator_traits::construct.
Summary:
Libcxx only supports compilers with variadics. We can safely remove all "fake" variadic overloads of allocator_traits::construct.

This also provides the correct behavior if anything other than exactly one argument is supplied to allocator_traits::construct in C++03 mode.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80067
2020-05-23 14:03:47 -07:00
Marek Kurdej 174322c273 [libc++] Mark __cpp_lib_hardware_interference_size as unimplemented. This fxes bug PR41423.
Summary:
As described in the bug report:
The commit a8b9f59e8caf378d56e8bfcecdb22184cdabf42d "Implement feature test macros using a script" added test features macros for libc++. Among others, it added `__cpp_lib_hardware_interference_size`. However, there is nothing like std::hardware_constructive_interference_size nor std::hardware_destructive_interference_size, that should be in header <new>.

* https://bugs.llvm.org/show_bug.cgi?id=41423

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D80431
2020-05-23 14:33:50 +02:00
Louis Dionne 485b9083fe [libc++] Mark __u64toa and __u32toa as noexcept
The two functions don't throw, and the generated code is better when
we explicitly tell the compiler that the functions are noexcept. This
isn't an ABI break because the signatures of the functions stay the
same with or without noexcept.

Fixes https://llvm.org/PR46016

Differential Revision: https://reviews.llvm.org/D80379
2020-05-22 16:11:44 -04:00
Louis Dionne 861b526933 [libc++] Fix broken tuple tests
The tests had copy-paste errors which started showing when an
unused-variable warning started being emitted after we made
the MoveOnly type constexpr (in a4b8ee6422).
2020-05-22 15:33:47 -04:00
Louis Dionne a4b8ee6422 [libc++] Make MoveOnly constexpr-friendly
This is necessary when writing constexpr tests.
2020-05-22 15:18:07 -04:00
Louis Dionne 0161874c04 [libc++] NFC: Inline array<T,N>::at methods inside the class
All other methods are defined in the class, so this increases consistency.
2020-05-22 09:24:07 -04:00
Marek Kurdej 0c148430cf Reland [libc++] [LWG3321] Mark "year_month_day_last::day() specification does not cover !ok() values" issue as "Nothing to do", but add assertion.
Summary:
This LWG issue states that the result of `year_month_day_last::day()` is implementation defined if `ok()` is `false`.
However, from user perspective, calling `day()` in this situation will lead to a (possibly difficult to find) crash.
Hence, I have added an assertion to warn user at least when assertions are enabled.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D70346
2020-05-21 21:55:38 +02:00
Louis Dionne 8f555780ef [libc++] Link back-deployment tests against the latest libc++ and libc++abi
Instead of linking the tests against a library in some version of the
SDK, always link against the latest library, but still run against the
specified back-deployment target dylib.

This makes more sense since what we're really trying to test is that
the current library can be used to produce binaries that run on some
deployment target -- not that linking against the library in some
previous SDK makes that possible.

This solves an additional issue that when linking against a system dylib,
the -rpath argument given to the tests is ignored because the install_name
of the system library we link against is absolute.

rdar://63241847
2020-05-21 14:47:04 -04:00
David Nicuesa 3411a1a920 Fix compile for -DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
Summary: Compilation with  -DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY was failing due to missing declarations of functions used in libcxx/include/atomic. The lines this commit affects are the places where those functions are defined, now moved to be always defined.

Reviewers: #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: miyuki, dexonsmith, ldionne, jfb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80372
2020-05-21 13:48:59 +01:00
Louis Dionne 9f19cc8cac [libcxx][test] Portability fix for some locale-dependent tests.
Tests for `std::system_error` constructor marked as slightly non-portable.
One (but not the only one) reason for such non-portability is that these
tests assume the default locale to be set to "C" (or "POSIX").

However, the default locale for the process depends on OS and
environment. This patch adds explicit setting of the correct
locale expected by the tests.

Thanks to Andrey Maksimov for the patch.

Differential Revision: https://reviews.llvm.org/D72456
2020-05-20 14:35:18 -04:00
Jan Wilken Dörrie 416b1560c5 [libcxx] Remove swap for std::span
This change removes both the member function swap and the free function
overload of swap for std::span. While swap is a member and overloaded
for every other container in the standard library [1], it is neither a
member function nor a free function overload for std::span [2].
Thus the corresponding implementation should be removed.

[1] https://eel.is/c++draft/libraryindex#:swap
[2] https://eel.is/c++draft/span.overview

Differential Revision: https://reviews.llvm.org/D69827
2020-05-20 14:34:21 -04:00
zoecarver ca5bff18fc [NFC] Remove non-rvlaue non-variadic allocator::construct overloads.
Summary: All supported compilers have rvalues and variadics so we can safely remove the overloads of allocator::construct which are only enabled on compilers without rvalues and variadics.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80068
2020-05-19 17:25:00 -07:00
zoecarver b8998ab9c2 [NFC] Remove non-rvlaue non-variadic allocator::construct overloads.
Summary: All supported compilers have rvalues and variadics so we can safely remove the overloads of allocator::construct which are only enabled on compilers without rvalues and variadics.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80068
2020-05-19 17:21:35 -07:00
zoecarver 21d4050e2c Mark shared_ptr::__create_with_control_block as noexcept.
Summary: The default constructor for shared_ptr and shared_ptr::__enable_weak_this are both noexcept so, shared_ptr::__create_with_control_block can also be marked noexcept.

Reviewers: ldionne, #libc!

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D80070
2020-05-19 17:17:16 -07:00
zoecarver c98648a175 [NFC] Add _EnableIfLValueCallable and move reference out of __callable.
Summary: In std::functional moves the reference out of the `__callable` implementation and replaces `_EnableIfCallable` with `_EnableIfLValueCallable` (`_EnableIfLValueCallable` passes `__callable` an lvalue reference type).

    Reviewers: ldionne, #libc!

    Subscribers: dexonsmith, libcxx-commits

    Tags: #libc

    Differential Revision: https://reviews.llvm.org/D80071
2020-05-19 17:15:28 -07:00
Michael Schellenberger Costa c579ab9962 [libcxx][type_traits] Add C++20 changes to common_type
Summary: This already implements the expected changes for LWG-3205

Reviewers: mclow.lists, EricWF, CaseyCarter, cjdb, #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, broadwaylamb, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D74350
2020-05-18 14:06:32 +02:00
David Zarzycki a675c1dee4 [libcxx testing] Remove ALLOW_RETRIES from lock_guard tests
These two tests were clumsily using time measurements to determine
whether std::lock_guard was working correctly. In practice, this
approach merely verified that the underlying lock properly waits.

Now these two tests verify that lock is acquired, not dropped
prematurely, and finally, actually dropped at the end of the scope.
2020-05-18 07:44:16 -04:00