[Bug libstdc++/78717] no definition of string::find when lowered to gimple

2022-08-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78717

--- Comment #4 from Jonathan Wakely  ---
This is because the std::basic_string::find function isn't marked 'inline' and
there is an explicit instantiation declaration for std::string. GCC simply
won't inline a non-inline function if there's an explicit instantiation of it.

With GCC 12 and -std=c++20 all members of std::basic_string are 'constexpr' and
so implicitly 'inline', and it gets inlined.

[Bug libstdc++/78717] no definition of string::find when lowered to gimple

2022-08-12 Thread hiraditya at msn dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78717

--- Comment #3 from AK  ---
Even with a high inline limit, string::find didn't inline.

g++-11.0.2 -O3  -finline-limit=10  -S -o a.s s.cpp

cat a.s

```
_Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_i:
.LFB1240:
.cfi_startproc
endbr64
pushq   %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movq8(%rsi), %rcx
movslq  %edx, %rbx
xorl%edx, %edx
movq(%rsi), %rsi
call   
_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEPKcmm@PLT
cmpq%rax, %rbx
popq%rbx
.cfi_def_cfa_offset 8
sete%al
movzbl  %al, %eax
ret

```

[Bug libstdc++/78717] no definition of string::find when lowered to gimple

2016-12-10 Thread hiraditya at msn dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78717

--- Comment #2 from AK  ---
With -O3 I see only the following definition of find which calls the real find
function I was expecting to be visible in the gimple.

  D.12805 =
_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findERKS4_mD.11635
(s1D.12794, s2D.12795, 0);

std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::find(const
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) const

But after I #defined _GLIBCXX_DEBUG in test.cpp (before including string), I
can see the find function.

[Bug libstdc++/78717] no definition of string::find when lowered to gimple

2016-12-10 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78717

--- Comment #1 from Marc Glisse  ---
Did you forget to enable optimizations? At -O0, there is no point keeping those
extern templates around, so gcc saves time by dropping them. At -O1 and above,
I do see some extra functions in the gimple dump. I don't see as many as if I
change _GLIBCXX_EXTERN_TEMPLATE to 0 in bits/c++config.h, some heuristic likely
decided to keep only the functions small enough that they are good candidates
for inlining (I didn't try to tweak the inlining parameters to see if I could
get it to keep all relevant functions).
I agree that this is not nice, there are several PRs in bugzilla caused by
those extern templates not being inlined aggressively enough. My hope is that
LTO will make enough progress that we can have libstdc++ compiled with it and
inline functions from the library.