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 AA82E385840C for ; Thu, 6 Jan 2022 10:34:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AA82E385840C Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-0Th-rhpXPB-fxzqh_gz-3A-1; Thu, 06 Jan 2022 05:33:58 -0500 X-MC-Unique: 0Th-rhpXPB-fxzqh_gz-3A-1 Received: by mail-yb1-f197.google.com with SMTP id e2-20020a25d302000000b0060c57942183so4279846ybf.18 for ; Thu, 06 Jan 2022 02:33:58 -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=dUMiCR7Xw7DGiYSnGNcRuwvuH+ob2CZi5fY4MJ9gHTY=; b=y7gUREg8C0BIaEM2OiXSdrPouUFhx696hAJ1pT9LHbjHFiqTQs7cK+xw1GoybfUma5 Gyoqknsrfd6GADJpZTjw3FR1PAirHUoEiwLey/DwdzEcfcddJ8BF/8r2ERdKIuraLeLU yQUmMSEftP0NZ7KMb8F5quZT+qi/ZVivkeVQGxU4BR3SkvZMJ4JdWOzC6lDlZ2P7V+vO DLke1OYrlLxhKJr84zyqtVe7jQ6evm5yqQquIqZwynXbwosvMIiP1t0O6GRAiy/jdqbp biPMNKKgODifA4bCxAcrFNz9zjfCO0fUDHmPbVUeId6AH/ejNx94UPUsR/w6d6kuiNmM 9VnQ== X-Gm-Message-State: AOAM532kSJidzycwQPL5T2iLKYdDhQLlAgvi1SoL8p9rWo/j1e0OQ203 WvkzYubgh5gPcuZm8WP1ULrgkjjXquQdKE6j3sA0AyxeAbb2EL64p871UuC/XjRLrgfsWri5krK Ol0SBDL6D7sHdRTGjOAGO0JpgyGjS5l0= X-Received: by 2002:a25:b082:: with SMTP id f2mr69999309ybj.316.1641465238095; Thu, 06 Jan 2022 02:33:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsDJuJXDn9jqlHM+E9/x3E8Hx7dX1Ppb7iM1hSFSED8ymDMqNvxWQH0JUuEjCE8eI0gR4wqChK/DTu5OZfW9g= X-Received: by 2002:a25:b082:: with SMTP id f2mr69999300ybj.316.1641465237899; Thu, 06 Jan 2022 02:33:57 -0800 (PST) MIME-Version: 1.0 References: <20220105134759.1639818-1-jwakely@redhat.com> <4010f9a9-bff0-c310-b6d6-ef3008a03fa5@redhat.com> In-Reply-To: <4010f9a9-bff0-c310-b6d6-ef3008a03fa5@redhat.com> From: Jonathan Wakely Date: Thu, 6 Jan 2022 10:33:46 +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 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:34:04 -0000 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