Commit Graph

6109 Commits

Author SHA1 Message Date
Atmn Patel 51b78a3e06 [libc++] Bugfix to std::binomial_distribution<int>
The current implementation of binomial_distribution is not guaranteed to
converge for certain extreme configurations of the engine and distribution.
This is due to a mistake in the implementation of the algorithm from the
given reference paper. The algorithm in the paper is guaranteed to
terminate but has redundant statements. The current implementation
simplified away the redundancy into a while loop, but it excludes the
return condition of the case where a good sample cannot be returned for
the particular sample being used from the uniform distribution, which is
what causes the infinite loop. This change guarantees termination by
recognizing that a good sample cannot be returned and returning 0 after
breaking the loop. This is also in contrast to the paper because the
return value as specified in the paper violates basic checks in at least
a subset of the extreme cases where the current implementation fails to
terminate. This default return value of 0 is satisfactory for the
extreme case known so far.

Since this is only meant to affect extreme cases where the algorithm
does not terminate anyways, the behavior is expected to remain exactly
the same for all non-extreme cases that have been terminating so far.

Fixes https://llvm.org/PR44847

Differential Revision: https://reviews.llvm.org/D74997
2020-03-17 15:56:16 -04:00
Louis Dionne 3d9e6c42f8 [libc++] Use env to set the tool's environment on Darwin 2020-03-17 15:40:51 -04:00
Dimitry Andric 585a3cc31b Fix -Wdeprecated-copy-dtor and -Wdeprecated-dynamic-exception-spec warnings.
Summary:
The former are like:

libcxx/include/typeinfo:322:11: warning: definition of implicit copy constructor for 'bad_cast' is deprecated because it has a user-declared destructor [-Wdeprecated-copy-dtor]
  virtual ~bad_cast() _NOEXCEPT;
          ^
libcxx/include/typeinfo:344:11: note: in implicit copy constructor for 'std::bad_cast' first required here
    throw bad_cast();
          ^

Fix these by adding an explicitly defaulted copy constructor.

The latter are like:

libcxx/include/codecvt:105:37: warning: dynamic exception specifications are deprecated [-Wdeprecated-dynamic-exception-spec]
    virtual int do_encoding() const throw();
                                    ^~~~~~~

Fix these by using the _NOEXCEPT macro instead.

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

Reviewed By: EricWF, #libc

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76150
2020-03-17 18:59:54 +01:00
Casey Carter 3609110967 Implement _LIBCPP_SUPPRESS_DEPRECATED_XXX when testing MSVC's STL
...to properly silence clang deprecation warnings in `test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp`.
2020-03-16 09:50:23 -07:00
Dan Albert 9c5d0ea678 Revert "Revert "Move more tests to globalMemCounter and reset.""
Test regressions not included this time :)

This reverts commit 1ed671082ef4b13d44e2c0f42ddedf9d450258a7.
2020-03-13 17:07:58 -07:00
Dan Albert 05749acfd3 Revert "Move more tests to globalMemCounter and reset."
Not all of these changes were correct. Will reland appropriate parts
in a follow up.

This reverts commit 4a792965de.
2020-03-13 13:26:35 -07:00
Dan Albert 14d2d8c976 Allow site-specific test_exec_root.
Reviewers: EricWF, mclow.lists, #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76092
2020-03-13 12:23:49 -07:00
Dan Albert adefcc8ab5 Revert "Revert "Update system_error tests for more platforms.""
This time using old fashioned starts_with.

This reverts commit d4a8c3f251.
2020-03-13 12:11:27 -07:00
Dan Albert d4a8c3f251 Revert "Update system_error tests for more platforms."
Can't use std::string::starts_with in tests.

This reverts commit a9740ff158.
2020-03-12 18:09:44 -07:00
Dan Albert a9740ff158 Update system_error tests for more platforms.
Reviewers: EricWF, mclow.lists, #libc, ldionne

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, libcxx-commits, cfe-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D35732
2020-03-12 17:37:46 -07:00
Dan Albert 4a792965de Move more tests to globalMemCounter and reset.
Summary:
Android's libc uses new/delete internally and these are counted, so
the counter needs to be reset to zero at the start of the test.

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

Reviewed By: #libc, ldionne

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D76091
2020-03-12 17:26:31 -07:00
Mark de Wever 56926a9146 Revert "[libcxx] Enable C++17 for the benchmarks."
It seems several build bots have issues with setting the CXX_STANDARD
property to 17.

This reverts commit d184d02263.
2020-03-12 22:23:46 +01:00
Mark de Wever d184d02263 [libcxx] Enable C++17 for the benchmarks.
The benchmarks are intended to be build with C++17 but the
CMAKE_CXX_STANDARD in the LLVM forces the build to use C++14 by default.
This fixes the issue by setting the CXX_STANDARD property of the benchmark
targets.

The CMake documentation is not clear whether this will use the C++1z
fallback for older compilers. So this may break the benchmarks if somebody
uses the benchmarks with pre C++17 compilers with the C++1z fallback.

Differential Revision: https://reviews.llvm.org/D75955
2020-03-12 21:35:00 +01:00
Marek Kurdej 05343588e3 [libc++] [P0646] Add feature-test macro for __cpp_lib_list_remove_return_type.
Summary: The return type modification has already been implemented in rL364840 and rL365290.

Reviewers: ldionne, mclow.lists, EricWF, #libc!

Reviewed By: ldionne

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D70275
2020-03-12 11:06:49 +01:00
Louis Dionne ee87b22a12 [libc+++] Mark two future tests as being FLAKY
They are timing sensitive.
2020-03-11 18:12:59 -04:00
Louis Dionne d34241a89d [libc++] Add SHA for C++20 Synchronization Library in ABI changelog
This is mostly a means to test a new Herald rule for libc++ reviews.

Differential Revision: https://reviews.llvm.org/D76022
2020-03-11 16:13:13 -04:00
Sergej Jaskiewicz ed77efeff1 [libc++] [cmake] Better diagnostics for missing abi library headers
Summary:
This is NFC. We only add additional information to the log.

Reviewers: EricWF, ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: kristof.beyls, dexonsmith, danielkiss, mgorny, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75991
2020-03-11 21:02:45 +03:00
Louis Dionne a13417352a [libc++] Properly mark std::function as deprecated in C++03
Due to Clang bug http://llvm.org/PR45151, deprecated attributes are not
picked up on partial specializations. This patch instead applies it to
the first declaration of std::function itself.
2020-03-10 17:45:39 -04:00
Louis Dionne 97d8d6ab38 [libc++] Enable std::function ABI bug demonstration on Apple Clang too 2020-03-09 15:03:34 -04:00
Louis Dionne 2b2a1a42c0 [libc++] Mark deprecation test as UNSUPPORTED on Clang 6 2020-03-04 19:32:40 -05:00
Martijn Vels b019c5c037 Partially inline basic_string copy constructor in UNSTABLE
Summary:
    This is a recommit of https://reviews.llvm.org/D73223 where the added function accidentally ended up inside an idef block.

    This change splits the copy constructor up inlining short initialization, and explicitly outlining long initialization into __init_copy_ctor_external() which is the externally instantiated slow path.

    For unstable ABI, this has the following changes:

    remove basic_string(const basic_string&)
    remove basic_string(const basic_string&, const Allocator&)
    add __init_copy_ctor_external(const value_type*, size_type)
    Quick local benchmark for Copy:

    Master
    ```
    ---------------------------------------------------------------
    Benchmark                    Time             CPU   Iterations
    ---------------------------------------------------------------
    BM_StringCopy_Empty       3.50 ns         3.51 ns    199326720
    BM_StringCopy_Small       3.50 ns         3.51 ns    199510016
    BM_StringCopy_Large       15.7 ns         15.7 ns     45230080
    BM_StringCopy_Huge        1503 ns         1503 ns       464896
    ```
    With this change
    ```
    ---------------------------------------------------------------
    Benchmark                    Time             CPU   Iterations
    ---------------------------------------------------------------
    BM_StringCopy_Empty       1.99 ns         2.00 ns    356471808
    BM_StringCopy_Small       3.29 ns         3.30 ns    203425792
    BM_StringCopy_Large       13.3 ns         13.3 ns     52948992
    BM_StringCopy_Huge        1472 ns         1472 ns       475136
    ```

    Subscribers: libcxx-commits

    Tags: #libc

    Differential Revision: https://reviews.llvm.org/D75639
2020-03-04 17:52:46 -05:00
Eric Fiselier 50b8088ba2 [libc++] Un-xfail GCC test for new version 2020-03-04 17:09:42 -05:00
Louis Dionne a27f29c6e4 [libc++] Fix typo in REQUIRES that broke the GCC-tot bot configuration
Explained in https://reviews.llvm.org/D70117#inline-688897.
2020-03-04 16:11:08 -05:00
Eric Fiselier 73b8d16e85 [libc++] Mark another test as flaky 2020-03-04 15:48:33 -05:00
Martijn Vels 3712edb152 Revert "Partially inline basic_string copy constructor in UNSTABLE"
This reverts commit 8cf76e913b.

We are investigating why this causes compilation issues under -O3
2020-03-04 14:52:17 -05:00
Louis Dionne c030ba64e4 [libc++] Avoid deprecation warning in the implementation of __has_rebind 2020-03-04 14:38:51 -05:00
Eric Fiselier 5891e7302f [libc++] Move std::string extern template declarations to end of class.
They need to appear before any member functions are ODR used, because
they change the visibility of many of these functions and otherwise
they could end up with hidden visibility in the DSO.
2020-03-04 13:57:29 -05:00
Louis Dionne 30cbdcb5c3 [libc++] Revert to previous implementation of __has_rebind
The new implementation introduced in 5b1e5b43 broke the bot running GCC 5.
2020-03-04 13:55:35 -05:00
Michael Park 5b1e5b4338 [libc++][P0174] Deprecated/removed parts of default allocator.
Differential Revision: https://reviews.llvm.org/D70117
2020-03-04 12:06:26 -05:00
Louis Dionne a2fe17cdc6 [libc++] Fix reverse_iterator test when UBSan is enabled
The goal of the test was only to check that we could access the
`this->current` member of std::reverse_iterator from a derived
class, but in doing so we incremented a null iterator, which is UB.
2020-03-04 11:35:34 -05:00
Louis Dionne 06dac0c39a [libc++] Mark the shared_future.wait_for test as being flaky
It is timing sensitive and it fails from time to time. If marking it as
flaky doesn't help, we can try tweaking the time outs.
2020-03-04 10:10:50 -05:00
Martijn Vels 8cf76e913b Partially inline basic_string copy constructor in UNSTABLE
his change splits the copy constructor up inlining short initialization, and explicitly outlining long initialization into __init_copy_ctor_external() which is the externally instantiated slow path.

For unstable ABI, this has the following changes:

remove basic_string(const basic_string&)
remove basic_string(const basic_string&, const Allocator&)
add __init_copy_ctor_external(const value_type*, size_type)
Quick local benchmark for Copy:

Master
```
---------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
---------------------------------------------------------------
BM_StringCopy_Empty       3.50 ns         3.51 ns    199326720
BM_StringCopy_Small       3.50 ns         3.51 ns    199510016
BM_StringCopy_Large       15.7 ns         15.7 ns     45230080
BM_StringCopy_Huge        1503 ns         1503 ns       464896
```

```
---------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
---------------------------------------------------------------
BM_StringCopy_Empty       1.99 ns         2.00 ns    356471808
BM_StringCopy_Small       3.29 ns         3.30 ns    203425792
BM_StringCopy_Large       13.3 ns         13.3 ns     52948992
BM_StringCopy_Huge        1472 ns         1472 ns       475136
```

Author: Martijn Vels <martijn.vels@gmail.com>

Reviewers: EricWF, mclow.list

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73223
2020-03-03 17:49:25 -05:00
Petr Hosek dffbaa4014 [libcxx] Drop -D option from libtool when merging archives
This is a follow up to D74108. This option is not supported by older
versions of libtool so remove it. We keep the -s option to build the
index.
2020-03-02 16:07:18 -08:00
Petr Hosek 603acd9626 [libcxx] When merging archives, build index even on Darwin
We always want to build the table of contents. Additionally, we also
set the flag to make the output deterministic which is already the
default for llvm-ar.

Differential Revision: https://reviews.llvm.org/D74108
2020-03-02 11:02:42 -08:00
Martijn Vels 675326466b Add flag _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATIONS for basic_string ABI
Summary: This review is a mostly trivial change to use an explicit ABI flag for the unstable external template list. This follows the practice for an ABI flag per feature, and provides a spot for the rational / motivation for the flag.

Reviewers: EricWF, ldionne

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75457
2020-03-02 10:26:37 -05:00
Martijn Vels f87d30cba2 Partially inline basic_string::operator=(const basic_string&)
Summary:
This change partially inlines operator=(const basic_string&) where both the input and current instance are short strings, making the assignment a fixed length inlined memcpy.

Assignments where either of the strings are long are delegate to __assign_no_alias<__is_short>(), which is templated for the long / short branch already observed in the caller.

Stable:
```
--------------------------------------------------------------------------------
Benchmark                                     Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_StringAssignStr_Empty_Opaque            2.65 ns         2.66 ns    263745536
BM_StringAssignStr_Empty_Transparent       2.95 ns         2.96 ns    236494848
BM_StringAssignStr_Small_Opaque            2.93 ns         2.94 ns    237301760
BM_StringAssignStr_Small_Transparent       2.69 ns         2.69 ns    265809920
BM_StringAssignStr_Large_Opaque            19.6 ns         19.6 ns     35573760
BM_StringAssignStr_Large_Transparent       19.1 ns         19.1 ns     36716544
BM_StringAssignStr_Huge_Opaque             1901 ns         1901 ns       364544
BM_StringAssignStr_Huge_Transparent        1889 ns         1889 ns       360448
```

Unstable
```
--------------------------------------------------------------------------------
Benchmark                                     Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_StringAssignStr_Empty_Opaque            1.29 ns         1.29 ns    540454912
BM_StringAssignStr_Empty_Transparent       1.11 ns         1.12 ns    628482048
BM_StringAssignStr_Small_Opaque            1.29 ns         1.29 ns    541216768
BM_StringAssignStr_Small_Transparent       1.11 ns         1.11 ns    629469184
BM_StringAssignStr_Large_Opaque            15.6 ns         15.6 ns     44945408
BM_StringAssignStr_Large_Transparent       14.9 ns         14.9 ns     46764032
BM_StringAssignStr_Huge_Opaque             1713 ns         1713 ns       401408
BM_StringAssignStr_Huge_Transparent        1704 ns         1704 ns       397312

```

Subscribers: libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75211
2020-03-02 09:58:11 -05:00
Eric Fiselier b4b4259a49 [libc++] update GCC cherry-pick to build 4.8.5 2020-02-28 13:36:35 -05:00
Eric Fiselier 0b8585ede4 [libc++] Update compiler images and more docker cleanup. 2020-02-27 17:22:58 -05:00
Eric Fiselier fdba2e4ed1 [libc++] Update lld version on buildbots to be LLVM-11. 2020-02-27 16:28:04 -05:00
Eric Fiselier 1d8fad44d3 [libc++] Rework docker files for buildbots.
I've been sitting on this change for a while and have been using
it to build the bot images, so it should be upstream.

This re-configures the docker build files to use docker-compose
more heavily. This allows for composing large images with multiple
compilers without invalidating the docker caches.

After this commit I'll quickly switch all the current buildbots
over to a new docker image, followed by another update to add new
compilers
2020-02-27 15:32:48 -05:00
Eric Fiselier d4ad2adb00 [libc++] Mark more try_lock tests as possibly flaky.
These tests check that an operations happens within a specified
deadline, which causes flaky failures on slow machines or machines
under heavy load.

By adding the // FLAKY_TEST. tag it allows the test suite to
retry or ignore the tests
2020-02-27 13:25:57 -05:00
ogiroux 621388468b Some fixes for open breaks on MacOS and UBSan 2020-02-26 20:51:19 -08:00
Louis Dionne 682e703755 [libc++] Workaround unused variable warning in test
This only showed up in C++11/C++14 where the static_assert below was
ifdef'd out, and the variable was indeed unused.
2020-02-26 19:30:10 -05:00
Louis Dionne 12339efd70 Revert "[libc++] Do not set the `availability=XXX` feature when not testing against a system libc++"
This reverts commit 7dd6a862e, which broke more tests than it fixed.
2020-02-26 19:20:14 -05:00
Louis Dionne a0ec111c92 [libc++] Temporarily disable availability markup for the C++20 Synchronization library
The markup wasn't quite right, and that broke compilation with availability
markup enabled. I'm disabling it until I have time to fix it properly to
get the CI mostly green again.
2020-02-26 19:10:27 -05:00
Martijn Vels d260ea7199 Inline basic_string::erase for fastpath where __n == npos
Summary:
This change checks for the case where people want to erase a string to the end, i.e., __n == npos, and inlines the call if so.

This also demonstrates keeping the ABI intact for V1, but inlining the erase() method for unstable.

Reviewers: EricWF, mclow.lists, ldionne

Reviewed By: EricWF, ldionne

Subscribers: smeenai, dexonsmith, christof, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D73743
2020-02-26 13:37:45 -05:00
Mikhail Maltsev 14aef5367d [libcxx] Fix _LIBCPP_HAS_THREAD_API_EXTERNAL build
Summary:
The definition of `__libcpp_timed_backoff_policy` and the declaration of
`__libcpp_thread_poll_with_backoff` must not be guarded by
  #if !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
because the definitions of `__libcpp_timed_backoff_policy::operator()`
and `__libcpp_thread_poll_with_backoff` aren't guarded by this macro
(and this is correct because these two functions are implemented in
terms of other libc++ functions and don't interact with the host
threading library).

Reviewers: ldionne, __simt__, EricWF, mclow.lists

Reviewed By: ldionne

Subscribers: dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75191
2020-02-26 17:54:43 +00:00
Martijn Vels 07eb82fc06 Add _LIBCPP_BUILTIN_CONSTANT_P support.
Summary:
This change adds the macros _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT and _LIBCPP_BUILTIN_CONSTANT_P to detect compile time constants, and optimze the code accordingly.

A planned usage example:
The implementation of basic_string::assign() can short-cut a compile time known short string assignent into a fast and compact inlined assignment:

```
basic_string::assign(const value_type* __s) {
  if (_LIBCPP_BUILTIN_CONSTANT_P(__s[0]) && length(__s) < __min_cap) {
    copy(pointer(), _s, length(__s) + 1);
    set_size(length(__s));
  } else {
    // delegate / tail call out of line implementation
  }
}
```

Subscribers: christof, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D73732
2020-02-26 11:03:51 -05:00
zoecarver 28d38a25e9 Remove std::shared_ptr::allocate_shared
std::shared_ptr::allocate_shared isn't in the standard. This commit removes it from libc++. It updates std::allocate_shared to use __create_with_cntrl_block.

Differential Revision: https://reviews.llvm.org/D66178
2020-02-25 16:50:57 -08:00
Louis Dionne b051cc9327 [NFC][libc++] Refactor some future tests to reduce code duplication
The same test was being repeated over and over again.
That's what functions are for.
2020-02-25 18:16:45 -05:00