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 E957A3858D39 for ; Thu, 6 Jan 2022 10:00:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E957A3858D39 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-MQTVN9NhMUSkJpEgBa--ug-1; Thu, 06 Jan 2022 05:00:21 -0500 X-MC-Unique: MQTVN9NhMUSkJpEgBa--ug-1 Received: by mail-wr1-f72.google.com with SMTP id l9-20020adfa389000000b001a23bd1c661so1031098wrb.6 for ; Thu, 06 Jan 2022 02:00:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:cc:from:in-reply-to :content-transfer-encoding; bh=7X59MJkUXjj+RdPOHYnl28Dg8sYPeOIfajko/oh7VeI=; b=Q6H8SfT6ASepJEAtoZZwfxhOv2kgFibL3a4lt0Di6hDMxXIK3kRpFETsvGQebWcv1d u93EqdgfLfz9rvj9gNzjAxCA260O5aDDWl0fcxhGz/WG/IvH4WflzrVGLAVqCDWcxN5h nGu/u0KHVtUbe8neZfQ74XbutcRu94BMEjVH4y/C2k5cEWEA1tFNxUDzjGyjW7FxtmWO Xw7ZxBrjeQBkGKJo67ZGMKKKvim2aBXrF6k8vvdrtceI2cEgbN+7BI8COVSYF+ImPydb aOwpQoVVxUuJ8far8sdhEieVEbS6gC+3v87F8L8cE7rqLCLTBu6VpJJbPFrjSv8K2QXj jxaw== X-Gm-Message-State: AOAM530rdbnzYKC4ccCfPqFgwW8A+pnPJ0ZYWUTW5CM+9pD97yp+0zQq U2kq5/fSRxfqTdOX5pPJTMQwnd+VjF52KJSuVTx+SI9B9L14K8d8f/AK6MOrlAlmYH+2nQlljt5 xqq931OU3ZoXs9l+w1A== X-Received: by 2002:a5d:6d8c:: with SMTP id l12mr49513001wrs.55.1641463220289; Thu, 06 Jan 2022 02:00:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgrlHsAUdKlPXBHLiAhJQFbJcS8Qey4LfiIk60Pi7YQyHuQYHhOnhT6COmoy4q/uCt9GERxQ== X-Received: by 2002:a5d:6d8c:: with SMTP id l12mr49512982wrs.55.1641463219974; Thu, 06 Jan 2022 02:00:19 -0800 (PST) Received: from [192.168.188.47] (dynamic-077-001-150-176.77.1.pool.telefonica.de. [77.1.150.176]) by smtp.gmail.com with ESMTPSA id p21sm1359367wmq.20.2022.01.06.02.00.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jan 2022 02:00:19 -0800 (PST) Message-ID: <4010f9a9-bff0-c310-b6d6-ef3008a03fa5@redhat.com> Date: Thu, 6 Jan 2022 11:00:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [committed] libstdc++: Reduce template instantiations in To: Jonathan Wakely References: <20220105134759.1639818-1-jwakely@redhat.com> Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org From: Stephan Bergmann In-Reply-To: <20220105134759.1639818-1-jwakely@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 06 Jan 2022 10:00:24 -0000 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.