libstdc++: Outline the overlapping case of string _M_replace into a separate function...
authorJakub Jelinek <jakub@redhat.com>
Mon, 12 Sep 2022 09:31:11 +0000 (11:31 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 12 Sep 2022 09:36:58 +0000 (11:36 +0200)
commit723ef5a937dbab5e7a35761fd7f0ff0c76849340
tree622b7ac694b7254a40656c7f87a6a2b352d4eca2
parent994ea892bd02dd8a1c04875ad3553c57939c3abf
libstdc++: Outline the overlapping case of string _M_replace into a separate function [PR105329]

The following patch is partially a workaround for bogus warnings
when the compiler isn't able to fold _M_disjunct call into constant
false, but also an optimization attempt - assuming _M_disjunct (__s)
is rare, the patch should shrink code size for the common case and
use library or for non-standard instantiations an out of line
function to handle the rare case.

2022-09-12  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105329
* acinclude.m4 (libtool_VERSION): Change to 6:31:0.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Don't export
std::basic_string methods with name length of 15.
(GLIBCXX_3.4.31): Export std::basic_string::_M_replace_cold.
* testsuite/util/testsuite_abi.cc (check_version): Handle
GLIBCXX_3.4.31.
* include/bits/basic_string.h (std::basic_string::_M_replace_cold):
Declare.
* include/bits/basic_string.tcc (std::basic_string::_M_replace_cold):
Define and export even for C++20.
(std::basic_string::_M_replace): Use __builtin_expect, outline
the overlapping case to _M_replace_cold.
* configure: Regenerated.
libstdc++-v3/acinclude.m4
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/configure
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/testsuite/util/testsuite_abi.cc