From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 18DB0385841A for ; Wed, 24 Aug 2022 22:47:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18DB0385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661381261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2yDpOvObT+H5pN/tywPsihYEmicMizehPHG/ozp4azs=; b=NqgnbRKnEM46jtqstNJqGbMgu73WqLyl39dRlH3GHILzjZ6b1bdDHW9ULGl6BojhDBNnMp UIqKwOTV+e/KiIpTc3W7cNVS/ODb6SzUZIXUtimu4MfXCG84witUDiXQAnux5dcm4/vXL1 LJi4+OcWsCXBqfOvn3aqyhUPUNvWLf0= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-484-UNCngh3SM7uTFqwH2rlkLQ-1; Wed, 24 Aug 2022 18:47:40 -0400 X-MC-Unique: UNCngh3SM7uTFqwH2rlkLQ-1 Received: by mail-qk1-f198.google.com with SMTP id bq19-20020a05620a469300b006bb70e293ccso15714383qkb.1 for ; Wed, 24 Aug 2022 15:47:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=2yDpOvObT+H5pN/tywPsihYEmicMizehPHG/ozp4azs=; b=lFhCRTW3WM1gxQgih4XdWaEXnuZpkPTnjtYWamiGIdtpih30KRoYP+v5tcB50Wul5H RvnKdO8KBUhyw5q10L0T1Mvf2Nd1dfsie30ZUux0acuNM9u7po6xPEoIWMjG2NUuhdGE WZVVMPA34jAIN2YnfC8KPPgb+qJniIW0T/GtZNT7ZFW+h24+MNdAcG2xLzyj5MAwxLGR IRwZ4wawLVUZn6TvLJw3YU1cOpW7Hvu3AbsQkPp8FKKkup2JeGv5QrrI8tQC3Li0aI4v cF7rJGjrjl3N+b0UNfhllt3fRTDH+dlCXH3dOsJUflVpP/RtDaGAWzSv4ccLWs6FuUgQ 2Tmg== X-Gm-Message-State: ACgBeo2nC61pI2MmjcQJlqqsb5bZpErafu5A5SNV5/3WJEAcN8dR0XXC 8gxVdC9L6wBomeV3iHOLO3Y5cehJtHunf51BsT2T0NA84YDDyaTSQp/eudq1DcwLI4XDI1G1lTY gNOUxi/9E+ZeA8fAvK+voz1/nPM+SoHJXDA== X-Received: by 2002:a05:6214:f0e:b0:496:e627:2d26 with SMTP id gw14-20020a0562140f0e00b00496e6272d26mr1297075qvb.42.1661381260152; Wed, 24 Aug 2022 15:47:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7JujnZqsAl7FaCtS0wrUD0OvA4xcsu7DB+/0mHClg3wkiIEcYMELAUgbkWayTzqqGKVIrXJdC0HNQh7wSf/44= X-Received: by 2002:a05:6214:f0e:b0:496:e627:2d26 with SMTP id gw14-20020a0562140f0e00b00496e6272d26mr1297059qvb.42.1661381259950; Wed, 24 Aug 2022 15:47:39 -0700 (PDT) MIME-Version: 1.0 References: <20220822181509.1032874-2-whh8b@obs.cr> <20220824061648.1119635-1-whh8b@obs.cr> <20220824061648.1119635-2-whh8b@obs.cr> In-Reply-To: From: Jonathan Wakely Date: Wed, 24 Aug 2022 23:47:29 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally To: Alexandre Oliva Cc: Jonathan Wakely via Gcc-patches , whh8b@obs.cr, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 24 Aug 2022 at 23:39, Alexandre Oliva wrote: > > On Aug 24, 2022, Jonathan Wakely via Gcc-patches 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; > 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&); > > > 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. To fix https://gcc.gnu.org/PR106735 I'm just going to revert it for now, and revisit in the morning.