https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109442

--- Comment #30 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Created attachment 59610
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59610&action=edit
patch for non-negative checks in std::vector::size and std::vector::capacity

This patch adds non-negativity checks to size and capacity.  With the patch to
ipa-fnsummary it should not have effect on inlining decisions and I would say
that any code quality regressions caused by the extra conditional should be
fixed at middle-end side.

I tested clang build.  Looking for throw_bad calls there are only 3 called
considerably often (bad_allloc, bad_array_new_length and function_callv).
The patch seems to reduce bad_alloc and bad_array_new_length calls
considerably:

bad_alloc 380->147
bad_array_new_length 832->128

I will test the _M_invariant patch same way.  While it should not have effect
on inliner (I will double-check), I am not sure it is a good idea.  It adds a
lot of loads to often uses size accessor which will take some effort for
middle-end to handle.

Reply via email to