aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-06-01 10:26:10 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-06-01 16:06:15 +0100
commitb7b255e77a271974479c34d1db3daafc04b920bc (patch)
tree75bdbfb1ca9c13ee9f4f3e19bb0ff8af4357b271 /gcc
parent8cbaf679a3c1875c5475bd1cb0fb86fb9d03b2d4 (diff)
downloadgcc-b7b255e77a271974479c34d1db3daafc04b920bc.zip
gcc-b7b255e77a271974479c34d1db3daafc04b920bc.tar.gz
gcc-b7b255e77a271974479c34d1db3daafc04b920bc.tar.bz2
libstdc++: Fix code size regressions in std::vector [PR110060]
My r14-1452-gfb409a15d9babc change to add optimization hints to std::vector causes regressions because it makes std::vector::size() and std::vector::capacity() too big to inline. That's the opposite of what I wanted, so revert the changes to those functions. To achieve the original aim of optimizing vec.assign(vec.size(), x) we can add a local optimization hint to _M_fill_assign, so that it doesn't affect all other uses of size() and capacity(). Additionally, add the same hint to the _M_assign_aux overload for forward iterators and add that to the testcase. It would be nice to similarly optimize: if (vec1.size() == vec2.size()) vec1 = vec2; but adding hints to operator=(const vector&) doesn't help. Presumably the relationships between the two sizes and two capacities are too complex to track effectively. libstdc++-v3/ChangeLog: PR libstdc++/110060 * include/bits/stl_vector.h (_Vector_base::_M_invariant): Remove. (vector::size, vector::capacity): Remove calls to _M_invariant. * include/bits/vector.tcc (vector::_M_fill_assign): Add optimization hint to reallocating path. (vector::_M_assign_aux(FwdIter, FwdIter, forward_iterator_tag)): Likewise. * testsuite/23_containers/vector/capacity/invariant.cc: Moved to... * testsuite/23_containers/vector/modifiers/assign/no_realloc.cc: ...here. Check assign(FwdIter, FwdIter) too. * testsuite/23_containers/vector/types/1.cc: Revert addition of -Wno-stringop-overread option.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions