llvm-project/libcxx/include
Eric Fiselier d4ace50ed0 Fix PR35637: suboptimal codegen for `vector<unsigned char>`.
The optimizer is petulant and temperamental. In this case LLVM failed to lower
the the "insert at end" loop used by`vector<unsigned char>` to a `memset` despite
`memset` being substantially faster over a range of bytes.

LLVM has the ability to lower loops to `memset` whet appropriate, but the
odd nature of libc++'s loops prevented the optimization from taking places.

This patch addresses the issue by rewriting the loops from the form
`do [ ... --__n; } while (__n > 0);` to instead use a for loop over a pointer
range (For example: `for (auto *__i = ...; __i < __e; ++__i)`).

This patch also rewrites the asan annotations to unposion all additional memory
at the start of the loop instead of once per iterations. This could potentially
permit false negatives where the constructor of element N attempts to access
element N + 1 during its construction.

The before and after results for the `BM_ConstructSize/vector_byte/5140480_mean`
benchmark (run 5 times) are:

--------------------------------------------------------------------------------------------
Benchmark                                                 Time             CPU   Iterations
--------------------------------------------------------------------------------------------
Before
------
BM_ConstructSize/vector_byte/5140480_mean          12530140 ns     12469693 ns            N/A
BM_ConstructSize/vector_byte/5140480_median        12512818 ns     12445571 ns            N/A
BM_ConstructSize/vector_byte/5140480_stddev          106224 ns       107907 ns            5
-----
After
-----
BM_ConstructSize/vector_byte/5140480_mean            167285 ns       166500 ns            N/A
BM_ConstructSize/vector_byte/5140480_median          166749 ns       166069 ns            N/A
BM_ConstructSize/vector_byte/5140480_stddev            3242 ns         3184 ns            5

llvm-svn: 367183
2019-07-28 04:37:02 +00:00
..
experimental [libcxx] Slightly improved policy for handling experimental features 2019-06-11 14:48:40 +00:00
ext Fix missing std:: qualifier in __gnu_cxx::hash_map in C++03 2019-05-17 20:59:57 +00:00
support [libc++] Remove empty header xlocale/xlocale.h 2019-03-11 15:41:51 +00:00
CMakeLists.txt Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
__bit_reference Reorganize the 'bit' header to make most of the facilities available for internal use pre-C++20. NFC for external users 2019-07-12 01:01:55 +00:00
__bsd_locale_defaults.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__bsd_locale_fallbacks.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__config [NFC][libcxx] Add comments about making mutex/condition_variable trivial on Apple platforms 2019-07-25 20:29:20 +00:00
__config_site.in Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
__debug Remove exception throwing debug mode handler support. 2019-03-18 21:50:12 +00:00
__errc Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__functional_03 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__functional_base Apply [[nodebug]] to typedefs throughout the STL. 2019-06-12 02:03:31 +00:00
__functional_base_03 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__hash_table Reorganize the 'bit' header to make most of the facilities available for internal use pre-C++20. NFC for external users 2019-07-12 01:01:55 +00:00
__libcpp_version Bump the trunk version to 10.0.0svn 2019-07-18 11:51:05 +00:00
__locale [libc++] Keep __regex_word in sync with ctype_base 2019-06-14 09:04:16 +00:00
__mutex_base Make ~mutex and ~condition_variable trivial on Windows. 2019-07-07 17:24:03 +00:00
__node_handle Avoid name conflict with kernel headers 2019-04-24 09:43:44 +00:00
__nullptr Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__split_buffer [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows 2017-05-31 22:07:49 +00:00
__sso_allocator Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__std_stream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__string Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
__threading_support __threading_support: Remove (void) in favor of (). 2019-07-01 16:18:38 +00:00
__tree Fix memory leak in set and map. 2019-07-11 23:13:38 +00:00
__tuple Apply new meta-programming traits throughout the library. 2019-06-23 20:28:29 +00:00
__undef_macros Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
algorithm Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
any [NFC][libc++] Remove stray semi-colon after function definition 2019-06-19 16:33:28 +00:00
array [libc++] Declare std::tuple_element as struct instead of class 2019-04-01 16:39:34 +00:00
atomic Add noexcept throughout <atomic> 2019-06-23 02:49:12 +00:00
bit Implement most of P1612R1: Relocate endian. Moves the std::endian functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that 2019-07-23 04:20:19 +00:00
bitset Ensure bitset's string constructor doesn't poison the overload set. 2019-07-01 19:59:34 +00:00
cassert Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ccomplex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cctype Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cerrno Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cfenv Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cfloat Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
charconv [libc++] Fix build with gcc 4.8 2019-06-13 22:27:24 +00:00
chrono Fix a bug in std::chrono::abs where it would fail when the duration's period had not been reduced.s 2019-07-26 15:10:46 +00:00
cinttypes Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ciso646 Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
climits Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
clocale Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cmath Apply new meta-programming traits throughout the library. 2019-06-23 20:28:29 +00:00
codecvt Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
compare Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
complex [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
complex.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
condition_variable Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
csetjmp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
csignal Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdarg Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdbool Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstddef Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdint Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdio Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstdlib Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cstring Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ctgmath Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ctime Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ctype.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cwchar Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
cwctype Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
deque Mark 'front()' and 'back()' as noexcept for array/deque/string/string_view. These are just rebranded 'operator[]', and should be noexcept like it is. 2019-03-19 03:30:07 +00:00
errno.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
exception Make move and forward work in C++03. 2019-06-21 15:20:55 +00:00
fenv.h Mark fenv.h as a system header before the #include_next directive 2019-03-29 16:03:57 +00:00
filesystem [libc++] Mark <filesystem> as unavailable on Apple platforms using pragmas 2019-03-20 21:18:14 +00:00
float.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
forward_list Make forward_list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out 2019-07-08 03:45:28 +00:00
fstream [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose fails 2019-07-22 19:54:34 +00:00
functional [libc++] Add C++17 deduction guides for std::function 2019-07-18 19:50:56 +00:00
future Assume __is_final, __is_base_of, and friends. 2019-06-21 13:56:13 +00:00
initializer_list [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
inttypes.h AIX system headers need stdint.h and inttypes.h to be re-enterable 2019-06-20 15:36:32 +00:00
iomanip [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
ios [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
iosfwd Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
iostream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
istream [libc++] Fix error flags and exceptions propagated from input stream operations 2019-04-05 16:33:37 +00:00
iterator [libc++] Take 2: Implement CTAD for map and multimap 2019-06-20 19:32:00 +00:00
limits Fix -Wdouble-promotion warnings. 2019-07-01 16:13:31 +00:00
limits.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
list Make forward_list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out 2019-07-08 03:45:28 +00:00
locale [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
locale.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
map [libc++] Use _EnableIf instead of std::enable_if in deduction guides for map and set 2019-07-19 17:13:39 +00:00
math.h Apply new meta-programming traits throughout the library. 2019-06-23 20:28:29 +00:00
memory Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
module.modulemap Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
mutex libc++/win: Make once_flag have the same size as a pointer. 2019-03-20 22:55:03 +00:00
new P0722R3: Implement library support for destroying delete 2019-05-23 23:46:44 +00:00
numeric Revert "[libc++] Integrate the PSTL into libc++" 2019-07-19 18:52:46 +00:00
optional Add a missing '__uncvref_t' to the SFINAE constraints for optional's assignment operator. Fixes PR38638. Thanks to Jonathan Wakely for the report 2019-06-27 18:40:55 +00:00
ostream Implement LWG2221: 'Formatted output for nullptr_t' Reviewed as: https://reviews.llvm.org/D63053 2019-07-01 16:20:25 +00:00
queue [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
random [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
ratio Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
regex [libc++] Keep __regex_word in sync with ctype_base 2019-06-14 09:04:16 +00:00
scoped_allocator Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
set [libc++] Use _EnableIf instead of std::enable_if in deduction guides for map and set 2019-07-19 17:13:39 +00:00
setjmp.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
shared_mutex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
span [libc++] Declare std::tuple_element as struct instead of class 2019-04-01 16:39:34 +00:00
sstream add a test and a couple minor bug fixes for the implicit-signed-integer-truncation sanitizer. This is PR#40566 2019-02-01 21:59:27 +00:00
stack [NFC][libcxx] Remove trailing whitespace 2019-05-29 16:01:36 +00:00
stdbool.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stddef.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stdexcept Fix ABI compatibility of `<stdexcept>` with VCRuntime. 2019-03-06 20:31:57 +00:00
stdint.h AIX system headers need stdint.h and inttypes.h to be re-enterable 2019-06-20 15:36:32 +00:00
stdio.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
stdlib.h Fix implementation of ::abs and std::abs LWG 2192. 2019-04-23 18:01:58 +00:00
streambuf Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
string [libc++] Fix link error with _LIBCPP_HIDE_FROM_ABI_PER_TU and std::string 2019-07-19 11:52:55 +00:00
string.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
string_view Provide hashers for string_view only if they are using the default char_traits. Seen on SO: test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp 2019-06-27 14:18:32 +00:00
strstream Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
system_error Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
tgmath.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
thread Fix backwards test that I committed yesterday. Sigh 2019-04-03 00:01:03 +00:00
tuple [NFC][libc++] Add missing EXPLICIT to pair and tuple synopsis 2019-07-22 20:45:23 +00:00
type_traits Implement most of P1612R1: Relocate endian. Moves the std::endian functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that 2019-07-23 04:20:19 +00:00
typeindex Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
typeinfo Fix build breakage on 32-bit machines 2019-05-29 02:38:19 +00:00
unordered_map Add contains method to associative containers. This patch implements P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset. 2019-07-16 03:21:01 +00:00
unordered_set Add contains method to associative containers. This patch implements P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset. 2019-07-16 03:21:01 +00:00
utility [NFC][libc++] Add missing EXPLICIT to pair and tuple synopsis 2019-07-22 20:45:23 +00:00
valarray Remove incorrect explicit instantiation declarations for valarray 2019-04-25 21:31:58 +00:00
variant Improve compile time of variant. 2019-07-14 21:29:39 +00:00
vector Fix PR35637: suboptimal codegen for `vector<unsigned char>`. 2019-07-28 04:37:02 +00:00
version P0722R3: Implement library support for destroying delete 2019-05-23 23:46:44 +00:00
wchar.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
wctype.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00