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 EA3653858D39 for ; Thu, 6 Jan 2022 10:00:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA3653858D39 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-304-PWsZcEReMWWBzInjxV62-Q-1; Thu, 06 Jan 2022 05:00:21 -0500 X-MC-Unique: PWsZcEReMWWBzInjxV62-Q-1 Received: by mail-wm1-f69.google.com with SMTP id r2-20020a05600c35c200b00345c3b82b22so2858151wmq.0 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=MMMJNNowZs7iq2aq5joRZ9UXtbllFqSB1olLlV14ufGVyR3geiikmOuDZhbNH8JlJT PNHaJL6akge9rW4HjpqCkhwZCt710YcgwafgBKdtuKiVKzh6Zismms9XZdxCudWy9LL6 uxkRqeH9nSaGDvCjZ2jXaO4fvG7H++WfSpS+bFAVlJ4VgJYxddFyhZVdc37S/lTQdbkN ZlXgf+R3OE8t0z4cSlq7vNdi2sQMNBLnyHxYBAz648HR163X2tecw5WJM0RX0qGkOdc/ S20+hpM5E04INK2d1xBz6cEU1dw4A3EgX2oqwWsssbfz2TkM6ZQxWN1Q7W+4paFFzaWO lN4A== X-Gm-Message-State: AOAM530ECc7o0//eSuY39betlAoEES2Dyg81hjWz3TTVA/0T723W8CPZ dkccUq8q3PO7Q1YXvBZTb1K5IxMDz7l3Ir+6OsiJ37yZQrg/08qe7YlXVS3XfO7DUtlsJOsMKV6 61GOPs/DlLGjaE0Y= X-Received: by 2002:a5d:6d8c:: with SMTP id l12mr49513003wrs.55.1641463220292; 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=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jan 2022 10:00:26 -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.