This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix non-Standard assumptions about how many elements are allocated
ClosedPublic

Authored by STL_MSFT on Oct 11 2016, 11:53 AM.

Details

Summary

The recently-added limited_allocator is much more conformant than the evil old stack_allocator. However, limited_allocator encodes non-Standard assumptions about how many allocations containers perform, which don't hold for MSVC. Specifically, MSVC's STL dynamically allocates sentinel nodes and "container proxies" (for debug mode checking), and its vector famously grows by 1.5x instead of 2x. I would like to retain the limited_allocator coverage, but tweak things so that they pass for both libc++ and MSVC.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
deque is too weird. (MSVC's deque reallocates its blockmap several times while doing this.) Just mark the tests as LIBCPP_ONLY, the coward's way out.

test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
test/std/containers/sequences/list/list.cons/size_type.pass.cpp
test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
"Add 2 for implementations that dynamically allocate a sentinel node and container proxy."

test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
"Add 1 for implementations that dynamically allocate a container proxy."

test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
Ditto. The (InIt, InIt) ctor is unchanged at 63 elements allocated (MSVC's 1.5x results in fewer element allocations, enough to make room for the container proxy).

test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
Adjust numbers for container proxy and 1.5x growth, with the calculations in the comments.

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 74280.Oct 11 2016, 11:53 AM
STL_MSFT retitled this revision from to [libcxx] [test] Fix non-Standard assumptions about how many elements are allocated.
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF accepted this revision.Oct 26 2016, 1:46 PM
EricWF edited edge metadata.

LGTM. I appreciate the doc for each of the magic numbers.

This revision is now accepted and ready to land.Oct 26 2016, 1:46 PM
STL_MSFT closed this revision.Oct 27 2016, 2:37 PM

Committed r285346. Thanks!!