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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7BD2D38618E2 for ; Mon, 28 Sep 2020 15:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7BD2D38618E2 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-vUHqkqVLPUaRquXyEy9y4A-1; Mon, 28 Sep 2020 11:38:40 -0400 X-MC-Unique: vUHqkqVLPUaRquXyEy9y4A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35CFB1868403; Mon, 28 Sep 2020 15:38:39 +0000 (UTC) Received: from localhost (unknown [10.33.36.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id C551D55763; Mon, 28 Sep 2020 15:38:38 +0000 (UTC) Date: Mon, 28 Sep 2020 16:38:38 +0100 From: Jonathan Wakely To: Patrick Palka Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH 4/4] libstdc++: Rearrange some range adaptors' data members Message-ID: <20200928153838.GH3946@redhat.com> References: <20200928044854.46674-1-ppalka@redhat.com> <20200928044854.46674-4-ppalka@redhat.com> <20200928093430.GD3946@redhat.com> <2accfda0-738-ea2b-8f58-abab7f122a78@idea> MIME-Version: 1.0 In-Reply-To: <2accfda0-738-ea2b-8f58-abab7f122a78@idea> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2020 15:38:45 -0000 On 28/09/20 09:11 -0400, Patrick Palka via Libstdc++ wrote: >On Mon, 28 Sep 2020, Jonathan Wakely wrote: > >> On 28/09/20 00:48 -0400, Patrick Palka via Libstdc++ wrote: >> > Since the standard range adaptors are specified to derive from the empty >> > class view_base, making their first data member store the underlying >> > view is suboptimal, for if the underlying view also derives from >> > view_base then the two view_base subobjects will be adjacent, thus >> > preventing the compiler from applying the empty base optimization to >> > elide away the storage for these two empty bases. >> > >> > This patch improves the situation by declaring the _M_base data member >> > last instead of first in each range adaptor that has more than one data >> > member, so that the empty base optimization can apply more often. >> > >> > Tested on x86_64-pc-linux-gnu with and wihout -m32. >> > >> > libstdc++-v3/ChangeLog: >> > >> > * include/std/ranges (filter_view::_M_base): Declare this data >> > member last. >> > (transform_view::_M_base): Likewise. >> > (take_view::_M_base): Likewise. >> > (take_while_view::_M_base): Likewise. >> > (drop_view::_M_base): Likewise. >> > (drop_while_view::_M_base): Likewise. >> > (join_view::_M_base): Likewise. >> > (split_view::_M_base): Likewise. >> > * testsuite/std/ranges/adaptors/sizeof.cc: Adjust expected >> > sizes. >> > --- >> > libstdc++-v3/include/std/ranges | 17 ++++++++--------- >> > .../testsuite/std/ranges/adaptors/sizeof.cc | 18 +++++++++--------- >> > 2 files changed, 17 insertions(+), 18 deletions(-) >> > >> > diff --git a/libstdc++-v3/include/std/ranges >> > b/libstdc++-v3/include/std/ranges >> > index 964a2b616a6..6fd8a85c2bf 100644 >> > --- a/libstdc++-v3/include/std/ranges >> > +++ b/libstdc++-v3/include/std/ranges >> > @@ -1250,9 +1250,9 @@ namespace views >> > { return __y.__equal(__x); } >> > }; >> > >> > - _Vp _M_base = _Vp(); >> > [[no_unique_address]] __detail::__box<_Pred> _M_pred; >> > [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin; >> > + _Vp _M_base = _Vp(); >> >> The constructor's mem-initializer-list needs to be reordered, to avoid >> warnings with -Wsystem-headers. > >Oops, fixed thusly. I noticed meanwhile that I forgot to move >reverse_view's _M_base member, so the below patch adds that as well. Nice to see testsuite/std/ranges/adaptors/sizeof.cc already proving useful by demonstrating the reduced sizes. >Tested on x86_64-pc-linux-gnu, and also verified that there are no new >-Wsystem-headers warnings. OK, thanks.