Commit Graph

6504 Commits

Author SHA1 Message Date
MinJae Hwang 8421364282 Modifications to the algorithm sort benchmark
Summary:
Modifies the algorithm sort bench:
- shows sorting time per element, instead of sorting time per array.
This would make comparison between different sizes of arrays easier.
- adds std::pair benchmark cases.
- uses a large number of arrays to benchmark, instead of repeatedly sorting the same array.
* sorting the same array again and again would not show actual sorting performance over randomized data sets.

Reviewers: EricWF, #libc, mvels

Reviewed By: EricWF, #libc, mvels

Subscribers: mgrang, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D81770
2020-07-06 18:30:02 -04:00
Stephan Herhut 3341d470fc Revert "Revert "Revert "[libcxx] Put clang::trivial_abi on std::unique_ptr, std::shared_ptr, and std::weak_ptr"""
This reverts commit f706b01a00.
2020-07-06 12:18:17 +02:00
Vy Nguyen f706b01a00 Revert "Revert "[libcxx] Put clang::trivial_abi on std::unique_ptr, std::shared_ptr, and std::weak_ptr""
This reverts commit dc13ac0280.

Rolling forward + fix typos and unused variables in tests

    Differential Revision: https://reviews.llvm.org/D82490
2020-07-05 13:44:42 -04:00
Vy Nguyen dc13ac0280 Revert "[libcxx] Put clang::trivial_abi on std::unique_ptr, std::shared_ptr, and std::weak_ptr"
This reverts commit 5cde3c9633.

The tests were reported failing on clang10
2020-07-04 11:29:08 -04:00
David Zarzycki e56e96a264 [libcxx testing] Remove ALLOW_RETRIES from another test 2020-07-04 10:15:21 -04:00
Vy Nguyen 5cde3c9633 [libcxx] Put clang::trivial_abi on std::unique_ptr, std::shared_ptr, and std::weak_ptr
Reviewers: jyknight, EricWF, #libc!

Subscribers: arphaman, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D82490
2020-07-03 17:23:13 -04:00
Louis Dionne 71d88cebfb [libc++/libc++abi] Automatically detect whether exceptions are enabled
Instead of detecting it automatically (in libc++) and relying on
_LIBCXXABI_NO_EXCEPTIONS being set explicitly (in libc++abi), always
detect whether exceptions are enabled automatically.

This commit also removes support for specifying -D_LIBCPP_NO_EXCEPTIONS
and -D_LIBCXXABI_NO_EXCEPTIONS explicitly -- those should just be inferred
from using -fno-exceptions (or an equivalent flag).

Allowing both -D_FOO_NO_EXCEPTIONS to be provided explicitly and trying
to detect it automatically is just confusing, especially since we did
specify it explicitly when building libc++abi. We should have only one
way to detect whether exceptions are enabled, but it should be robust.
2020-07-03 14:58:09 -04:00
David Zarzycki 8aff689164 [libcxx testing] Remove ALLOW_RETRIES from another test 2020-07-03 07:00:34 -04:00
Louis Dionne 1eb211ada1 [libc++] Translate the std Lit parameter to the DSL 2020-06-30 16:51:20 -04:00
Louis Dionne 99f213e07c [libc++] Fix the Lit DSL test in case a substitution is empty 2020-06-30 14:52:51 -04:00
Louis Dionne 73370b2c0c [libc++] Add missing include in test 2020-06-30 14:16:47 -04:00
Louis Dionne ce6153a528 [libc++] Split dylib instantiations for deprecated std::random_shuffle into a separate source file
That makes it easier to exclude from the build if one wants to build libc++
without support for the deprecated std::random_shuffle.
2020-06-30 13:50:17 -04:00
Louis Dionne 70f6389257 [runtimes] Rename newformat to just format, now that the old format has been removed 2020-06-30 10:10:30 -04:00
Louis Dionne b58b61c4b7 [libc++] Remove dead code since the removal of the old testing format 2020-06-30 10:07:59 -04:00
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