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 79C8E3858CD1 for ; Fri, 14 Jul 2023 18:07:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79C8E3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689358075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g8mRcWC1W6PmcpWfq4n7JGJwcxzYXcSLZHDk0pxwtaw=; b=bV5kTdohQr4VUWkVUFO8K9Op7kVNa8IgUw3lQ/dHAs1vHHMZaWsd9v6Sygxpy0iqiVqG1r yFz+TJrXIlZbehJpizET/NUevlfjEv6UXRW5XUhHl07s6IhL+BqF47BF7tIwECw5EAagMD hg59KgDPJ16+XKW66LnZKUizFq/V+XM= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-wNCgBaJWMYe_uRFMy2UGgQ-1; Fri, 14 Jul 2023 14:07:53 -0400 X-MC-Unique: wNCgBaJWMYe_uRFMy2UGgQ-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-5649d12abe1so3131385eaf.2 for ; Fri, 14 Jul 2023 11:07:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689358072; x=1691950072; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uwsHrvSQP4uGkCZE0/lcn7B1MXmbB5alqRrKLoFKhjM=; b=Kpgwz8r9aAk2X0Bkf7ih2zMw6In+cYUHFWLnR9RY3G+gGLCIM17j4bNLcs2wNUvFpT sllh8LUwtQJXI8exGEs3LdHONKmOptHsFLINf7jSHPKXHm+9MWhygiQDxVie3DCLFb5S LUCBosECDnsqOxV2cxnY6jukQarkEVyWCsw6pUPxSi4VKGtfcSMYaK6bl+a7snVZ7oRa h3UifSg3DYlDUnu7fWCLWUbKy0oejCkYEp85F3xPui8R4riVVRFUNroMXMd5PA6Dn4K0 LNxB0STJmweO/79sEwGDlX0oaaTUcBqeVwg42MF/P9uVawVgINtQxQIU8zdwe/b1K/Bt 3KNg== X-Gm-Message-State: ABy/qLbZuBwI2quCY2zWdbguX0uw3BvQXEZCtP5Ikd2MQQO9ZDBkjAML rWZBI9Cb32TqYCIrfXBB+yxbZ2YuwQdlwLWEjNfxBtRHQheDXT6m7s2HtzGc/Oo916qrmRiXpOK lEuDJ5l17V7jNZsklNQ== X-Received: by 2002:a05:6808:1645:b0:3a3:7977:8995 with SMTP id az5-20020a056808164500b003a379778995mr6063724oib.47.1689358071980; Fri, 14 Jul 2023 11:07:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8mFRdOO+tvE4GXsvhP+GbzCDgvvxFB+M9GllBSM4Ay7ltTwOgbBn//OR8EWhvy1TGA1j+sQ== X-Received: by 2002:a05:6808:1645:b0:3a3:7977:8995 with SMTP id az5-20020a056808164500b003a379778995mr6063706oib.47.1689358071454; Fri, 14 Jul 2023 11:07:51 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id 24-20020a05620a079800b00767da9b6ae9sm3991741qka.11.2023.07.14.11.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 11:07:50 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 14 Jul 2023 14:07:50 -0400 (EDT) To: Jason Merrill cc: Patrick Palka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: redundant targ coercion for var/alias tmpls In-Reply-To: Message-ID: <9e51de65-9910-445b-1ec7-8a3cd47114fc@idea> References: <20230621171920.1283054-1-ppalka@redhat.com> <94b29e42-dfa9-5c05-4f1d-3c5beb998fdf@redhat.com> <26258d18-5718-9387-087b-be58a25048c2@redhat.com> <4388a939-94bd-048c-f234-e54bab92d937@idea> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="8323329-1568243027-1689358070=:2236" X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1568243027-1689358070=:2236 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Thu, 13 Jul 2023, Jason Merrill wrote: > On 7/13/23 11:48, Patrick Palka wrote: > > On Wed, 28 Jun 2023, Patrick Palka wrote: > > > > > On Wed, Jun 28, 2023 at 11:50 AM Jason Merrill wrote: > > > > > > > > On 6/23/23 12:23, Patrick Palka wrote: > > > > > On Fri, 23 Jun 2023, Jason Merrill wrote: > > > > > > > > > > > On 6/21/23 13:19, Patrick Palka wrote: > > > > > > > When stepping through the variable/alias template specialization > > > > > > > code > > > > > > > paths, I noticed we perform template argument coercion twice: > > > > > > > first from > > > > > > > instantiate_alias_template / finish_template_variable and again > > > > > > > from > > > > > > > tsubst_decl (during instantiate_template). It should suffice to > > > > > > > perform > > > > > > > coercion once. > > > > > > > > > > > > > > To that end patch elides this second coercion from tsubst_decl > > > > > > > when > > > > > > > possible. We can't get rid of it completely because we don't > > > > > > > always > > > > > > > specialize a variable template from finish_template_variable: we > > > > > > > could > > > > > > > also be doing so directly from instantiate_template during > > > > > > > variable > > > > > > > template partial specialization selection, in which case the > > > > > > > coercion > > > > > > > from tsubst_decl would be the first and only coercion. > > > > > > > > > > > > Perhaps we should be coercing in lookup_template_variable rather > > > > > > than > > > > > > finish_template_variable? > > > > > > > > > > Ah yes, there's a patch for that at > > > > > https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617377.html :) > > > > > > > > So after that patch, can we get rid of the second coercion completely? > > > > > > On second thought it should be possible to get rid of it, if we > > > rearrange things to always pass the primary arguments to tsubst_decl, > > > and perform partial specialization selection from there instead of > > > instantiate_template. Let me try... > > > > Like so? Bootstrapped and regtested on x86_64-pc-linux-gnu. > > > > -- >8 -- > > > > When stepping through the variable/alias template specialization code > > paths, I noticed we perform template argument coercion twice: first from > > instantiate_alias_template / finish_template_variable and again from > > tsubst_decl (during instantiate_template). It'd be good to avoid this > > redundant coercion. > > > > It turns out that this coercion could be safely elided whenever > > specializing a primary variable/alias template, because we can rely on > > lookup_template_variable and instantiate_alias_template to already have > > coerced the arguments. > > > > The other situation to consider is when fully specializing a partial > > variable template specialization (from instantiate_template), in which > > case the passed 'args' are the (already coerced) arguments relative to > > the partial template and 'argvec', the result of substitution into > > DECL_TI_ARGS, are the (uncoerced) arguments relative to the primary > > template, so coercion is still necessary. We can still avoid this > > coercion however if we always pass the primary variable template to > > tsubst_decl from instantiate_template, and instead perform partial > > specialization selection directly from tsubst_decl. This patch > > implements this approach. > > The relationship between instantiate_template and tsubst_decl is pretty > tangled. We use the former to substitute (often deduced) template arguments > into a template, and the latter to substitute template arguments into a use of > a template...and also to implement the former. > > For substitution of uses of a template, we expect to need to coerce the > arguments after substitution. But we avoid this issue for variable templates > by keeping them as TEMPLATE_ID_EXPR until substitution time, so if we see a > VAR_DECL in tsubst_decl it's either a non-template variable or under > instantiate_template. FWIW it seems we could also be in tsubst_decl for a VAR_DECL if * we're partially instantiating a class-scope variable template during instantiation of the class * we're substituting a use of an already non-dependent variable template specialization > > So it seems like the current coercion for variable templates is only needed in > this case to support the redundant hash table lookup that we just did in > instantiate_template. Perhaps instead of doing coercion here or moving the > partial spec lookup, we could skip the hash table lookup for the case of a > variable template? It seems we'd then also have to make instantiate_template responsible for registering the variable template specialization since tsubst_decl no longer necessarily has the arguments relative to the primary template ('args' could be relative to the partial template). Like so? The following makes us perform all the specialization table manipulation in instantiate_template instead of tsubst_decl for variable template specializations. I wonder if we might want to do this for alias template specializations too? -- >8 -- gcc/cp/ChangeLog: * pt.cc (tsubst_decl) : Exit early for a non-dependent variable template specialization. Don't look up or register a variable template specialization when called from instantiate_template. (instantiate_template): Register a variable template specialization here. --- gcc/cp/pt.cc | 53 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 2b2c598c3a9..3a9d43d383d 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -15192,6 +15192,14 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (!(VAR_P (t) && DECL_LOCAL_DECL_P (t)) && (DECL_CLASS_SCOPE_P (t) || DECL_NAMESPACE_SCOPE_P (t))) { + if (variable_template_specialization_p (t) + && !uses_template_parms (INNERMOST_TEMPLATE_ARGS + (DECL_TI_ARGS (t)))) + { + r = t; + break; + } + local_p = false; if (DECL_CLASS_SCOPE_P (t)) { @@ -15222,20 +15230,21 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) { tmpl = DECL_TI_TEMPLATE (t); gen_tmpl = most_general_template (tmpl); - argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl); - if (argvec != error_mark_node - && PRIMARY_TEMPLATE_P (gen_tmpl) - && TMPL_ARGS_DEPTH (args) >= TMPL_ARGS_DEPTH (argvec)) - /* We're fully specializing a template declaration, so - we need to coerce the innermost arguments corresponding to - the template. */ - argvec = (coerce_template_parms - (DECL_TEMPLATE_PARMS (gen_tmpl), - argvec, tmpl, complain)); - if (argvec == error_mark_node) - RETURN (error_mark_node); - hash = spec_hasher::hash (gen_tmpl, argvec); - spec = retrieve_specialization (gen_tmpl, argvec, hash); + if (variable_template_p (tmpl) + && (TMPL_ARGS_DEPTH (args) + >= TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (gen_tmpl)))) + /* We're fully specializing a variable template via + instantiate_template, which already attempted to look + up the specialization, and will be also responsible for + registering the specialization. */; + else + { + argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl); + if (argvec == error_mark_node) + RETURN (error_mark_node); + hash = spec_hasher::hash (gen_tmpl, argvec); + spec = retrieve_specialization (gen_tmpl, argvec, hash); + } } } else @@ -15397,7 +15406,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec); SET_DECL_IMPLICIT_INSTANTIATION (r); - if (!error_operand_p (r) || (complain & tf_error)) + if (argvec + && (!error_operand_p (r) || (complain & tf_error))) register_specialization (r, gen_tmpl, argvec, false, hash); } else @@ -22032,7 +22042,8 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) - /* It would be nice to avoid hashing here and then again in tsubst_decl, - but it doesn't seem to be on the hot path. */ - spec = retrieve_specialization (gen_tmpl, targ_ptr, 0); + hashval_t hash = spec_hasher::hash (gen_tmpl, targ_ptr); + spec = retrieve_specialization (gen_tmpl, targ_ptr, hash); gcc_checking_assert (tmpl == gen_tmpl || ((fndecl @@ -22122,9 +22133,13 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) DECL_TI_TEMPLATE (fndecl) = tmpl; DECL_TI_ARGS (fndecl) = targ_ptr; if (VAR_P (pattern)) - /* Now that we we've formed this variable template specialization, - remember the result of most_specialized_partial_spec for it. */ - TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (fndecl)) = partial_ti; + { + /* Now that we we've formed this variable template specialization, + remember the result of most_specialized_partial_spec for it. */ + TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (fndecl)) = partial_ti; + /* And register the specialization, which tsubst_decl deferred to us. */ + register_specialization (fndecl, gen_tmpl, targ_ptr, false, hash); + } set_instantiating_module (fndecl); -- 2.41.0.327.gaa9166bcc0 > > > gcc/cp/ChangeLog: > > > > * pt.cc (tsubst_decl) : Don't call > > coerce_template_parms. Call most_specialized_partial_spec > > when fully specializing a variable template here ... > > (instantiate_template): ... instead of here. Always pass > > the primary variable template pattern to tsubst_decl. > > --- > > gcc/cp/pt.cc | 62 +++++++++++++++++++++++----------------------------- > > 1 file changed, 27 insertions(+), 35 deletions(-) > > > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > > index fa15b75b9c5..53968b823d5 100644 > > --- a/gcc/cp/pt.cc > > +++ b/gcc/cp/pt.cc > > @@ -15194,6 +15194,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t > > complain) > > /* Check to see if we already have the specialization we > > need. */ > > tree spec = NULL_TREE; > > + tree partial_ti = NULL_TREE; > > bool local_p = false; > > tree ctx = DECL_CONTEXT (t); > > if (!(VAR_P (t) && DECL_LOCAL_DECL_P (t)) > > @@ -15230,17 +15231,29 @@ tsubst_decl (tree t, tree args, tsubst_flags_t > > complain) > > tmpl = DECL_TI_TEMPLATE (t); > > gen_tmpl = most_general_template (tmpl); > > argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl); > > - if (argvec != error_mark_node > > - && PRIMARY_TEMPLATE_P (gen_tmpl) > > - && TMPL_ARGS_DEPTH (args) >= TMPL_ARGS_DEPTH (argvec)) > > - /* We're fully specializing a template declaration, so > > - we need to coerce the innermost arguments corresponding > > to > > - the template. */ > > - argvec = (coerce_template_parms > > - (DECL_TEMPLATE_PARMS (gen_tmpl), > > - argvec, tmpl, complain)); > > if (argvec == error_mark_node) > > RETURN (error_mark_node); > > + if (variable_template_p (gen_tmpl) > > + && TMPL_ARGS_DEPTH (args) >= TMPL_ARGS_DEPTH (argvec)) > > + { > > + /* We need to determine if we're using a partial > > + specialization now, because the type of the > > + variable could be different. */ > > + iloc_sentinel ils (saved_loc); > > + tree tid = build_nt (TEMPLATE_ID_EXPR, gen_tmpl, argvec); > > + partial_ti = most_specialized_partial_spec (tid, > > complain); > > + if (partial_ti == error_mark_node) > > + RETURN (error_mark_node); > > + else if (partial_ti) > > + { > > + tree partial_tmpl = TI_TEMPLATE (partial_ti); > > + tree partial_args = TI_ARGS (partial_ti); > > + tree partial_pat = DECL_TEMPLATE_RESULT > > (partial_tmpl); > > + t = partial_pat; > > + args = partial_args; > > + in_decl = partial_pat; > > + } > > + } > > hash = spec_hasher::hash (gen_tmpl, argvec); > > spec = retrieve_specialization (gen_tmpl, argvec, hash); > > If you disagree with my suggestion above, the hash lookup should come before > the partial specialization selection. Makes sense. Here's this updated approach for comparison: gcc/cp/ChangeLog: * pt.cc (tsubst_decl) : Don't call coerce_template_parms. Call most_specialized_partial_spec when fully specializing a variable template here ... (instantiate_template): ... instead of here. Always pass the primary variable template pattern to tsubst_decl. --- gcc/cp/pt.cc | 63 +++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index fa15b75b9c5..3987ffc509a 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -15194,6 +15194,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* Check to see if we already have the specialization we need. */ tree spec = NULL_TREE; + tree partial_ti = NULL_TREE; bool local_p = false; tree ctx = DECL_CONTEXT (t); if (!(VAR_P (t) && DECL_LOCAL_DECL_P (t)) @@ -15230,15 +15231,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) tmpl = DECL_TI_TEMPLATE (t); gen_tmpl = most_general_template (tmpl); argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl); - if (argvec != error_mark_node - && PRIMARY_TEMPLATE_P (gen_tmpl) - && TMPL_ARGS_DEPTH (args) >= TMPL_ARGS_DEPTH (argvec)) - /* We're fully specializing a template declaration, so - we need to coerce the innermost arguments corresponding to - the template. */ - argvec = (coerce_template_parms - (DECL_TEMPLATE_PARMS (gen_tmpl), - argvec, tmpl, complain)); if (argvec == error_mark_node) RETURN (error_mark_node); hash = spec_hasher::hash (gen_tmpl, argvec); @@ -15270,6 +15262,28 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) break; } + if (gen_tmpl + && variable_template_p (gen_tmpl) + && TMPL_ARGS_DEPTH (args) >= TMPL_ARGS_DEPTH (argvec)) + { + /* We need to determine if we're using a partial specialization + now, because the type of the variable could be different. */ + iloc_sentinel ils (saved_loc); + tree tid = build_nt (TEMPLATE_ID_EXPR, gen_tmpl, argvec); + partial_ti = most_specialized_partial_spec (tid, complain); + if (partial_ti == error_mark_node) + RETURN (error_mark_node); + else if (partial_ti) + { + tree partial_tmpl = TI_TEMPLATE (partial_ti); + tree partial_args = TI_ARGS (partial_ti); + tree partial_pat = DECL_TEMPLATE_RESULT (partial_tmpl); + t = partial_pat; + args = partial_args; + in_decl = partial_pat; + } + } + /* Create a new node for the specialization we need. */ if (type == NULL_TREE) { @@ -15403,6 +15417,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) DECL_NOT_REALLY_EXTERN (r) = 1; DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec); + if (variable_template_p (tmpl)) + /* Now that we we've formed this variable template specialization, + remember the result of most_specialized_partial_spec for it. */ + TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (r)) = partial_ti; SET_DECL_IMPLICIT_INSTANTIATION (r); if (!error_operand_p (r) || (complain & tf_error)) register_specialization (r, gen_tmpl, argvec, false, hash); @@ -22092,29 +22110,8 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) tree pattern = DECL_TEMPLATE_RESULT (gen_tmpl); - tree partial_ti = NULL_TREE; - fndecl = NULL_TREE; - if (VAR_P (pattern)) - { - /* We need to determine if we're using a partial or explicit - specialization now, because the type of the variable could be - different. */ - tree tid = build2 (TEMPLATE_ID_EXPR, NULL_TREE, tmpl, targ_ptr); - partial_ti = most_specialized_partial_spec (tid, complain); - if (partial_ti == error_mark_node) - pattern = error_mark_node; - else if (partial_ti) - { - tree partial_tmpl = TI_TEMPLATE (partial_ti); - tree partial_args = TI_ARGS (partial_ti); - tree partial_pat = DECL_TEMPLATE_RESULT (partial_tmpl); - fndecl = tsubst (partial_pat, partial_args, complain, gen_tmpl); - } - } - /* Substitute template parameters to obtain the specialization. */ - if (fndecl == NULL_TREE) - fndecl = tsubst (pattern, targ_ptr, complain, gen_tmpl); + fndecl = tsubst (pattern, targ_ptr, complain, gen_tmpl); if (DECL_CLASS_SCOPE_P (gen_tmpl)) pop_nested_class (); pop_from_top_level (); @@ -22129,10 +22126,6 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) template, not the most general template. */ DECL_TI_TEMPLATE (fndecl) = tmpl; DECL_TI_ARGS (fndecl) = targ_ptr; - if (VAR_P (pattern)) - /* Now that we we've formed this variable template specialization, - remember the result of most_specialized_partial_spec for it. */ - TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (fndecl)) = partial_ti; set_instantiating_module (fndecl); -- 2.41.0.327.gaa9166bcc0 > > > } > > @@ -15403,6 +15416,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t > > complain) > > DECL_NOT_REALLY_EXTERN (r) = 1; > > DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec); > > + if (variable_template_p (tmpl)) > > + /* Now that we we've formed this variable template > > specialization, > > + remember the result of most_specialized_partial_spec for it. > > */ > > + TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (r)) = partial_ti; > > SET_DECL_IMPLICIT_INSTANTIATION (r); > > if (!error_operand_p (r) || (complain & tf_error)) > > register_specialization (r, gen_tmpl, argvec, false, hash); > > @@ -22092,29 +22109,8 @@ instantiate_template (tree tmpl, tree orig_args, > > tsubst_flags_t complain) > > tree pattern = DECL_TEMPLATE_RESULT (gen_tmpl); > > - tree partial_ti = NULL_TREE; > > - fndecl = NULL_TREE; > > - if (VAR_P (pattern)) > > - { > > - /* We need to determine if we're using a partial or explicit > > - specialization now, because the type of the variable could be > > - different. */ > > - tree tid = build2 (TEMPLATE_ID_EXPR, NULL_TREE, tmpl, targ_ptr); > > - partial_ti = most_specialized_partial_spec (tid, complain); > > - if (partial_ti == error_mark_node) > > - pattern = error_mark_node; > > - else if (partial_ti) > > - { > > - tree partial_tmpl = TI_TEMPLATE (partial_ti); > > - tree partial_args = TI_ARGS (partial_ti); > > - tree partial_pat = DECL_TEMPLATE_RESULT (partial_tmpl); > > - fndecl = tsubst (partial_pat, partial_args, complain, gen_tmpl); > > - } > > - } > > - > > /* Substitute template parameters to obtain the specialization. */ > > - if (fndecl == NULL_TREE) > > - fndecl = tsubst (pattern, targ_ptr, complain, gen_tmpl); > > + fndecl = tsubst (pattern, targ_ptr, complain, gen_tmpl); > > if (DECL_CLASS_SCOPE_P (gen_tmpl)) > > pop_nested_class (); > > pop_from_top_level (); > > @@ -22129,10 +22125,6 @@ instantiate_template (tree tmpl, tree orig_args, > > tsubst_flags_t complain) > > template, not the most general template. */ > > DECL_TI_TEMPLATE (fndecl) = tmpl; > > DECL_TI_ARGS (fndecl) = targ_ptr; > > - if (VAR_P (pattern)) > > - /* Now that we we've formed this variable template specialization, > > - remember the result of most_specialized_partial_spec for it. */ > > - TI_PARTIAL_INFO (DECL_TEMPLATE_INFO (fndecl)) = partial_ti; > > set_instantiating_module (fndecl); > > > > --8323329-1568243027-1689358070=:2236--