darling-libcxx/benchmarks
Eric Fiselier e7f817d01d 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@367183 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-28 04:37:02 +00:00
..
algorithms.bench.cpp Add benchmarks for sorting and heap functions. 2018-11-20 17:15:17 +00:00
algorithms.partition_point.bench.cpp [libcxx] Speeding up partition_point/lower_bound/upper_bound 2018-12-17 16:04:39 +00:00
CartesianBenchmarks.hpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
CMakeLists.txt [libc++][CMake] Refactor how we link against system libraries 2019-04-30 15:44:19 +00:00
ContainerBenchmarks.hpp Fix PR35637: suboptimal codegen for vector<unsigned char>. 2019-07-28 04:37:02 +00:00
filesystem.bench.cpp Implement filesystem NB comments, relative paths, and related issues. 2018-04-02 23:03:41 +00:00
function.bench.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
GenerateInput.hpp Implement filesystem NB comments, relative paths, and related issues. 2018-04-02 23:03:41 +00:00
lit.cfg.py Rename cxx-benchmark-unittests target and convert to LIT. 2018-11-14 20:38:46 +00:00
lit.site.cfg.py.in Rename cxx-benchmark-unittests target and convert to LIT. 2018-11-14 20:38:46 +00:00
ordered_set.bench.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
string.bench.cpp Add more benchmarks for literal strings. 2019-04-03 17:40:51 +00:00
stringstream.bench.cpp Add test macros for always_inline and noinline 2018-10-10 18:22:23 +00:00
unordered_set_operations.bench.cpp Add test macros for always_inline and noinline 2018-10-10 18:22:23 +00:00
util_smartptr.bench.cpp Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
vector_operations.bench.cpp Fix PR35637: suboptimal codegen for vector<unsigned char>. 2019-07-28 04:37:02 +00:00