From: Will Hawkins <hawkinsw@obs.cr>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: Alexandre Oliva <oliva@gnu.org>,
Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org>,
libstdc++@gcc.gnu.org
Subject: Re: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally
Date: Thu, 25 Aug 2022 01:52:08 -0400 [thread overview]
Message-ID: <CADx9qWibPttAuR7XqzmOAvMBWv=LJNi7yxDn+frVuNEANU8Qtw@mail.gmail.com> (raw)
In-Reply-To: <CACb0b4nS2P292yftUpkxjr=wtzKqwZ1msCaRP9fVcErVeniV+g@mail.gmail.com>
On Wed, Aug 24, 2022 at 7:03 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Wed, 24 Aug 2022 at 23:47, Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > On Wed, 24 Aug 2022 at 23:39, Alexandre Oliva <oliva@gnu.org> wrote:
> > >
> > > On Aug 24, 2022, Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > > * include/bits/basic_string.h (operator+(const string&,
> > > > const char*)):
> > > > Remove naive implementation.
> > > > * include/bits/basic_string.tcc (operator+(const string&,
> > > > const char*)):
> > > > Add single-allocation implementation.
> > >
> > > ISTM this requires the following additional tweak:
> > >
> > > diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc
> > > index bfae6d902a1dd..2ec0e9d85f947 100644
> > > --- a/libstdc++-v3/src/c++11/string-inst.cc
> > > +++ b/libstdc++-v3/src/c++11/string-inst.cc
> > > @@ -58,6 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> > >
> > > template class basic_string<C>;
> > > template S operator+(const C*, const S&);
> > > + template S operator+(const S&, const C*);
> > > template S operator+(C, const S&);
> > > template S operator+(const S&, const S&);
> > >
I realize that I should have noticed that asymmetry as well. Sorry!
> > >
> > > Without this, I'm getting undefined references to this specialization in
> > > libstdc++.so, that I tracked down to a std::system_error ctor in
> > > cxx11-ios_failure.o. I got this while testing another patch that might
> > > be the reason why the template instantiation doesn't get inlined, but...
> > > we can't depend on its being inlined, can we?
> >
> > Right. But adding that will cause another symbol to be exported,
> > probably with the wrong symbol version.
>
> Oh, but those symbols aren't exported ... they're just needed because
> we compile with -fno-implicit-templatesand other symbols in
> libstdc++.so require them.
>
> So that probably is the right fix. I have another change for operator+
> in mind now anyway, which optimizes operator(const string&, char) the
> same way, and removes the duplication in those five operator+
> overloads.
Let me know if/how I can help.
Will
>
> >
> > To fix https://gcc.gnu.org/PR106735 I'm just going to revert it for
> > now, and revisit in the morning.
>
prev parent reply other threads:[~2022-08-25 5:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 18:15 whh8b
2022-08-22 18:15 ` whh8b
2022-08-23 16:33 ` Jonathan Wakely
2022-08-24 6:18 ` Will Hawkins
2022-08-24 9:49 ` Jonathan Wakely
2022-08-24 6:16 ` [PATCH v2] libstdc++: Optimize operator+(string/char*,string/char*) whh8b
2022-08-24 6:16 ` [PATCH] libstdc++: Optimize operator+(string/char*,string/char*) equally whh8b
2022-08-24 6:16 ` [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally whh8b
2022-08-24 14:24 ` Jonathan Wakely
2022-08-24 22:39 ` Alexandre Oliva
2022-08-24 22:47 ` Jonathan Wakely
2022-08-24 23:02 ` Jonathan Wakely
2022-08-25 5:52 ` Will Hawkins [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADx9qWibPttAuR7XqzmOAvMBWv=LJNi7yxDn+frVuNEANU8Qtw@mail.gmail.com' \
--to=hawkinsw@obs.cr \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=oliva@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).