]> gcc.gnu.org Git - gcc.git/commit
c++: further optimize tsubst_template_decl
authorPatrick Palka <ppalka@redhat.com>
Wed, 20 Sep 2023 16:07:15 +0000 (12:07 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 20 Sep 2023 16:07:15 +0000 (12:07 -0400)
commit915574e538322aad5195bc3b6be2a4f85bbd2467
tree23dff84f3051ac24ab4b3c1c5618895e6f74fe8d
parent1a554a2c9f33fdb3c170f1c37274037ece050114
c++: further optimize tsubst_template_decl

This patch makes tsubst_template_decl use use_spec_table=false also in
the non-class non-function template case, to avoid computing 'argvec' and
doing a hash table lookup from tsubst_decl (when partially instantiating
a member variable/alias template).

This change reveals that for function templates, tsubst_template_decl
registers the partially instantiated TEMPLATE_DECL, whereas for other
non-class templates it registers the corresponding DECL_TEMPLATE_RESULT
which is an interesting inconsistency that I decided to preserve for now.
Trying to consistently register the TEMPLATE_DECL (or DECL_TEMPLATE_RESULT)
causes modules ICEs which I didn't look into.

In passing, in tsubst_function_decl I noticed 'argvec' is unused
when 'lambda_fntype' is set (since lambdas aren't recorded in the
specializations table), so we can avoid computing it in that case.

gcc/cp/ChangeLog:

* pt.cc (tsubst_function_decl): Don't bother computing 'argvec'
when 'lambda_fntype' is set.
(tsubst_template_decl): Make sure we return a TEMPLATE_DECL
during specialization lookup.  In the non-class non-function
template case, use tsubst_decl directly with use_spec_table=false,
update DECL_TI_ARGS and call register_specialization like
tsubst_decl would have done if use_spec_table=true.
gcc/cp/pt.cc
This page took 0.053004 seconds and 5 git commands to generate.