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 162DB385801F for ; Thu, 6 Jan 2022 10:44:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 162DB385801F 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-12-XVfq1KmZNRWCKnWI8C2Naw-1; Thu, 06 Jan 2022 05:43:59 -0500 X-MC-Unique: XVfq1KmZNRWCKnWI8C2Naw-1 Received: by mail-yb1-f197.google.com with SMTP id v189-20020a2561c6000000b0060b5814a17eso4265837ybb.22 for ; Thu, 06 Jan 2022 02:43:59 -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=sBgddmd+Il2sgKy8f0rtzkvLmwyro/sI7gCfTO/4H3Q=; b=26c+ge7Qw0LAmwJ6vf8nRx9tln1croVEsM8i6hPumY0G5HfxrF/GGM1qVG+PXA+piI HS6VWThyT9xJUBk8h+xgI794DxbCOx9Lqz17iCfM0pj2yonqnZ8xahMl0z7nBztqZdjW ucxQ484QDKwD+Azym5/b4eny2mvh5/oKzxcxOsquKEA8zno5FfHawlI3RG3kn084pKlC a+MQzfeQpkQT2GBUwsUE3fk2QoSsZ94SAxd2iZ84lx3RfR/Myhvkv/QQllwmrCpVwpr9 UwrpFONUWLzjFi2i58ABtVr5WDhfS8OpdG+nS1G8VvkTuAWdgA0ZPMJftpty8IRik0vT WeAw== X-Gm-Message-State: AOAM533aO9vWOIxHU4F+yhG/jf3r95ANtUfuIDQMQMPQ/2zOCmhbD/kY jlsQdHueT0TO65xqIWCXZ8TBo6Ga1dEs8F2hMIG88f0MBFGuxj17ogj8BuqhRVFbir1qDW5kFoO ZzXvp3Wfo8hTTbh7r1saZsPGnmkLWD7k= X-Received: by 2002:a25:d142:: with SMTP id i63mr64055129ybg.253.1641465838594; Thu, 06 Jan 2022 02:43:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYoU/P0eHKCg1gt1EbKMQuSzN9zg2/pOj5IbO7Hhi9VdMCWtTW1f/t3RA0bwafHoRu8wPH33sN/1Nl5zWyk+E= X-Received: by 2002:a25:d142:: with SMTP id i63mr64055113ybg.253.1641465838374; Thu, 06 Jan 2022 02:43:58 -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 10:43:47 +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=-13.0 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:44:06 -0000 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