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.129.124]) by sourceware.org (Postfix) with ESMTPS id 112793858012 for ; Thu, 6 Jan 2022 15:00:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 112793858012 Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-0Q_uZNNVPfC50HCYsno2nw-1; Thu, 06 Jan 2022 10:00:01 -0500 X-MC-Unique: 0Q_uZNNVPfC50HCYsno2nw-1 Received: by mail-yb1-f198.google.com with SMTP id s127-20020a252c85000000b0060be2b7b8e9so5489288ybs.8 for ; Thu, 06 Jan 2022 07:00:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=67wuJb1h3BifaOB3IU8cUo4iYpKk6D8AqMo15hsx73A=; b=LJJinWTDBE8x/AmItHfuD4PDMRRXKwzkiYx43/nVFKpZfk5kF/2R3ddVi4359Q62Em tpYnaHkyV2Lvd+iqd0HVeZq+TzK/RqGinvpZ2nr7JaToEP2jEUeFjwtk5YEIkVZYaRS3 Jrb354O/J0RZzqEuwrBpPlrHI4rMKQnqw94YnEQpsBVKFxJUlQH0GOLEdOgnISA/pWZh dqUN5h6D2mo99ATBecf9jX+xgf/SJ1cyuad6Iw1niGPYdfGiHHitYww5QebTveoRuzrd loWGVdq+4oHNYmxzR0SX8zUhMHJudazIGqhlyqTWCZy3nPyVmOkbNvdgwdF82XFgUABY RILA== X-Gm-Message-State: AOAM530tI3Ox4JeI89g77heqsgUmQ07SnfeODleYbfO/mgmpgc+w9G3C z+JdTHgjOgVecjCBR2vmzTPwK11J1t96IeaM9ehrywwh4aAmX28yWgIEjjzB8jOZ8djjxDNJGgv AWaILLEXvJv4WyktC2WX8Mn1jU6IFbGA/rA== X-Received: by 2002:a25:d696:: with SMTP id n144mr57496056ybg.13.1641481200204; Thu, 06 Jan 2022 07:00:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9tJeeIe8GiFPxFtV241S7Z2e7HY3NCbfzQYMbh1W02EESIptWS5rYYK8YQxkLbpBjzAPjWtvvrlogDYZSl0c= X-Received: by 2002:a25:d696:: with SMTP id n144mr57496032ybg.13.1641481199976; Thu, 06 Jan 2022 06:59:59 -0800 (PST) MIME-Version: 1.0 References: <20220105134759.1639818-1-jwakely@redhat.com> <4010f9a9-bff0-c310-b6d6-ef3008a03fa5@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Thu, 6 Jan 2022 14:59:48 +0000 Message-ID: Subject: Re: [committed] libstdc++: Reduce template instantiations in To: Stephan Bergmann Cc: "libstdc++" , gcc Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="000000000000d4bb2205d4eb1f9d" X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 06 Jan 2022 15:00:10 -0000 --000000000000d4bb2205d4eb1f9d Content-Type: text/plain; charset="UTF-8" On Thu, 6 Jan 2022 at 10:43, Jonathan Wakely wrote: > > > On Thu, 6 Jan 2022 at 10:33, Jonathan Wakely wrote: > >> >> >> On Thu, 6 Jan 2022 at 10:00, Stephan Bergmann >> wrote: >> >>> On 05/01/2022 14:47, Jonathan Wakely via Libstdc++ wrote: >>> > Tested powerpc64le-linux, pushed to trunk. >>> > >>> > >>> > This moves the last two template parameters of __regex_algo_impl to be >>> > runtime function parameters instead, so that we don't need four >>> > different instantiations for the possible ways to call it. Most of the >>> > function (and what it instantiates) is the same in all cases, so making >>> > them compile-time choices doesn't really have much benefit. >>> > >>> > Use 'if constexpr' for conditions that check template parameters, so >>> > that when we do depend on a compile-time condition we only instantiate >>> > what we need to. >>> > >>> > libstdc++-v3/ChangeLog: >>> > >>> > * include/bits/regex.h (__regex_algo_impl): Change __policy and >>> > __match_mode template parameters to be function parameters. >>> > (regex_match, regex_search): Pass policy and match mode as >>> > function arguments. >>> > * include/bits/regex.tcc (__regex_algo_impl): Change template >>> > parameters to function parameters. >>> > * include/bits/regex_compiler.h (_RegexTranslatorBase): Use >>> > 'if constexpr' for conditions using template parameters. >>> > (_RegexTranslator): Likewise. >>> > * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): >>> > Likewise. >>> > * testsuite/util/testsuite_regex.h (regex_match_debug) >>> > (regex_search_debug): Move template arguments to function >>> > arguments. >>> > --- >>> > libstdc++-v3/include/bits/regex.h | 33 >>> +++++++++---------- >>> > libstdc++-v3/include/bits/regex.tcc | 8 ++--- >>> > libstdc++-v3/include/bits/regex_compiler.h | 9 ++--- >>> > libstdc++-v3/include/bits/regex_executor.tcc | 2 +- >>> > libstdc++-v3/testsuite/util/testsuite_regex.h | 24 +++++++------- >>> > 5 files changed, 37 insertions(+), 39 deletions(-) >>> >>> Clang now fails #include with >>> >>> > In file included from >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/regex:66: >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:799:9: >>> error: unknown type name '_RegexExecutorPolicy'; did you mean >>> '__detail::_RegexExecutorPolicy'? >>> > _RegexExecutorPolicy, bool); >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >>> note: '__detail::_RegexExecutorPolicy' declared here >>> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:2070:9: >>> error: unknown type name '_RegexExecutorPolicy'; did you mean >>> '__detail::_RegexExecutorPolicy'? >>> > _RegexExecutorPolicy, bool); >>> > ^ >>> > >>> gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/regex.h:45:14: >>> note: '__detail::_RegexExecutorPolicy' declared here >>> > enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; >>> > ^ >>> >>> and >>> >>> > diff --git a/libstdc++-v3/include/bits/regex.h >>> b/libstdc++-v3/include/bits/regex.h >>> > index 7480b0a5f97..46c168010bf 100644 >>> > --- a/libstdc++-v3/include/bits/regex.h >>> > +++ b/libstdc++-v3/include/bits/regex.h >>> > @@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >>> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >>> > const basic_regex<_Cp, _Rp>&, >>> > regex_constants::match_flag_type, >>> > - _RegexExecutorPolicy, bool); >>> > + __detail::_RegexExecutorPolicy, >>> bool); >>> > >>> > template >>> > friend class __detail::_Executor; >>> > @@ -2067,7 +2067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >>> > __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, >>> > const basic_regex<_Cp, _Rp>&, >>> > regex_constants::match_flag_type, >>> > - _RegexExecutorPolicy, bool); >>> > + __detail::_RegexExecutorPolicy, >>> bool); >>> > >>> > // Reset contents to __size unmatched sub_match objects >>> > // (plus additional objects for prefix, suffix and unmatched >>> sub). >>> >>> would fix that. >>> >> >> >> I'll make the change, but this looks like a clang bug: >> https://godbolt.org/z/bozxYErrc >> > > Maybe this one: https://github.com/llvm/llvm-project/issues/38230 > I've pushed the fix now, thanks for the report. --000000000000d4bb2205d4eb1f9d Content-Type: text/plain; charset="US-ASCII"; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ky33im6i0 Y29tbWl0IGVjMTJkZGQxZTdmN2Q2YjQ4YTU5M2RmODY1ZTc4NDYwMzllN2Q2MmUKQXV0aG9yOiBK b25hdGhhbiBXYWtlbHkgPGp3YWtlbHlAcmVkaGF0LmNvbT4KRGF0ZTogICBUaHUgSmFuIDYgMTE6 MTE6NTIgMjAyMgoKICAgIGxpYnN0ZGMrKzogQWRqdXN0IGZyaWVuZCBkZWNsYXJhdGlvbnMgdG8g d29yayB3aXRoIENsYW5nCiAgICAKICAgIEkgdGhpbmsgdGhpcyBjb2RlIGlzIHZhbGlkIGJ1dCBp dCBmYWlscyB3aXRoIENsYW5nLCBwb3NzaWJseSBkdWUgdG8KICAgIGh0dHBzOi8vbGx2bS5vcmcv UFIzODg4MgogICAgCiAgICBRdWFsaWZ5aW5nIHRoZSBuYW1lcyBtYWtlcyBpdCB3b3JrIGZvciBh bGwgY29tcGlsZXJzLgogICAgCiAgICBsaWJzdGRjKystdjMvQ2hhbmdlTG9nOgogICAgCiAgICAg ICAgICAgICogaW5jbHVkZS9iaXRzL3JlZ2V4LmggKGJhc2ljX3JlZ2V4LCBtYXRjaF9yZXN1bHRz KTogUXVhbGlmeQogICAgICAgICAgICBuYW1lIGluIGZyaWVuZCBkZWNsYXJhdGlvbiwgdG8gd29y ayBhcm91bmQgQ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