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 928D9396E05C for ; Tue, 31 May 2022 19:07:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 928D9396E05C Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-2ebu8QZyOc21XPPmbaroog-1; Tue, 31 May 2022 15:07:02 -0400 X-MC-Unique: 2ebu8QZyOc21XPPmbaroog-1 Received: by mail-qk1-f200.google.com with SMTP id i2-20020a05620a144200b006a3a8651de1so11190662qkl.14 for ; Tue, 31 May 2022 12:07:01 -0700 (PDT) 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:cc:references:from:in-reply-to :content-transfer-encoding; bh=xtC5skHWtGmJuPTs4uADx60dkr1nolTB6ateuPsB8gw=; b=fkNWJx8UlVsxBs2rUaQWNy0+j7izgeYHRXc+deJaijH0PUePLIHnAUD1n9RaqzgVCU FgC+aghy0RHOdodYeqb5CQXYKYGRWUVeZMWsOlM+GD/Shz7+zAqYfEBqNDshSaCQgVLh CTuZHwlmigiB3jJ3MZ3iZEsaXlBl3ZQ52aKFYlYoWe8MriPbHTvzPNX3PrRm2LDFsFbw kvw9D/cbjvm2gJCPH5135k6OiMEHlShpr1b1P5EsqxhKWzYgyrs91uz6t2vPLmfSD6dM nLNpL6IBQ/rD31k9ozdWUHORCF+OENaN+wOKa6vbbNqLmYQ68WhIOo64tifBRtXv5BID DWiQ== X-Gm-Message-State: AOAM533nwXWcAn+3sCyHUhfKmy27qnjyw4T6mvRLzdl7ZaDzsDE+bgq/ zIqRd8tp8wCcTzJOxKVz5meMQ9C3ddDjE9IXMVsjdWFtVrmrappdyk0JAa6pMmPY+eBvXLj4tja Oa8Zs+B56+zwZowUzNw== X-Received: by 2002:a37:a544:0:b0:6a3:3abf:a095 with SMTP id o65-20020a37a544000000b006a33abfa095mr40158112qke.238.1654024021376; Tue, 31 May 2022 12:07:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUpUo6Vd3kvnMMcpRfFboOA5A/7U6US3XbBd+Yk0y1WkmvXHwdIy/7G60yXUa5wgfloHEn6A== X-Received: by 2002:a37:a544:0:b0:6a3:3abf:a095 with SMTP id o65-20020a37a544000000b006a33abfa095mr40158077qke.238.1654024020914; Tue, 31 May 2022 12:07:00 -0700 (PDT) Received: from [192.168.1.100] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id x2-20020a05620a0ec200b006a3769b8133sm7355145qkm.73.2022.05.31.12.06.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 May 2022 12:06:59 -0700 (PDT) Message-ID: Date: Tue, 31 May 2022 15:06:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] c++: use auto_timevar instead of timevar_push/pop To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20220531173457.334065-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: 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=-14.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_DNSWL_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2022 19:07:05 -0000 On 5/31/22 13:47, Patrick Palka wrote: > On Tue, 31 May 2022, Patrick Palka wrote: > >> r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with >> auto_cond_timevar and removed now unnecessary wrapper functions. This >> patch does the same for timevar_push/pop and auto_timevar. >> >> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >> trunk? OK. >> gcc/cp/ChangeLog: >> >> * parser.cc: >> * pt.cc: >> Use auto_timevar instead of timevar_push/pop. >> Remove wrapper functions. >> --- >> gcc/cp/parser.cc | 31 ++++++++---------------- >> gcc/cp/pt.cc | 61 +++++++++++------------------------------------- >> 2 files changed, 24 insertions(+), 68 deletions(-) >> >> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc >> index 21066421a02..3acfbd43c5b 100644 >> --- a/gcc/cp/parser.cc >> +++ b/gcc/cp/parser.cc >> @@ -19106,7 +19106,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) >> cp_decl_specifier_seq decl_specifiers; >> tree extension_specifier = NULL_TREE; >> >> - timevar_push (TV_TEMPLATE_INST); >> + auto_timevar time (TV_TEMPLATE_INST); > > Er, I named the new variables 'time' to be consistent with the existing > uses of auto_timevar in constexpr/constraint/logic.cc, but on second > thought 'tv', as used by r12-5487-g9bf69a8558638c, seems better. > So consider the names changed to 'tv': > > -- >8 -- > > Subject: [PATCH] c++: use auto_timevar instead of timevar_push/pop > > r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with > auto_cond_timevar and removed now unnecessary wrapper functions. This > patch does the same with timevar_push/pop and auto_timevar. > > gcc/cp/ChangeLog: > > * parser.cc: > * pt.cc: > Use auto_timevar instead of timevar_push/pop. > Remove wrapper functions. > --- > gcc/cp/parser.cc | 37 +++++++++++------------------ > gcc/cp/pt.cc | 61 +++++++++++------------------------------------- > 2 files changed, 27 insertions(+), 71 deletions(-) > > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc > index 21066421a02..5a52c32f38b 100644 > --- a/gcc/cp/parser.cc > +++ b/gcc/cp/parser.cc > @@ -19106,7 +19106,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) > cp_decl_specifier_seq decl_specifiers; > tree extension_specifier = NULL_TREE; > > - timevar_push (TV_TEMPLATE_INST); > + auto_timevar tv (TV_TEMPLATE_INST); > > /* Look for an (optional) storage-class-specifier or > function-specifier. */ > @@ -19207,8 +19207,6 @@ cp_parser_explicit_instantiation (cp_parser* parser) > > cp_parser_consume_semicolon_at_end_of_statement (parser); > > - timevar_pop (TV_TEMPLATE_INST); > - > cp_finalize_omp_declare_simd (parser, &odsd); > } > > @@ -20966,7 +20964,8 @@ cp_parser_enum_specifier (cp_parser* parser) > elaborated-type-specifier. */ > if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) > { > - timevar_push (TV_PARSE_ENUM); > + auto_timevar tv (TV_PARSE_ENUM); > + > if (nested_name_specifier > && nested_name_specifier != error_mark_node) > { > @@ -21072,7 +21071,6 @@ cp_parser_enum_specifier (cp_parser* parser) > > if (scoped_enum_p) > finish_scope (); > - timevar_pop (TV_PARSE_ENUM); > } > else > { > @@ -25927,9 +25925,11 @@ pop_injected_parms (void) > > Returns the TREE_TYPE representing the class. */ > > -static tree > -cp_parser_class_specifier_1 (cp_parser* parser) > +tree > +cp_parser_class_specifier (cp_parser* parser) > { > + auto_timevar tv (TV_PARSE_STRUCT); > + > tree type; > tree attributes = NULL_TREE; > bool nested_name_specifier_p; > @@ -26321,16 +26321,6 @@ cp_parser_class_specifier_1 (cp_parser* parser) > return type; > } > > -static tree > -cp_parser_class_specifier (cp_parser* parser) > -{ > - tree ret; > - timevar_push (TV_PARSE_STRUCT); > - ret = cp_parser_class_specifier_1 (parser); > - timevar_pop (TV_PARSE_STRUCT); > - return ret; > -} > - > /* Parse a class-head. > > class-head: > @@ -31276,15 +31266,14 @@ cp_parser_function_definition_from_specifiers_and_declarator > } > else > { > - timevar_id_t tv; > + timevar_id_t tv_id; > if (DECL_DECLARED_INLINE_P (current_function_decl)) > - tv = TV_PARSE_INLINE; > + tv_id = TV_PARSE_INLINE; > else > - tv = TV_PARSE_FUNC; > - timevar_push (tv); > + tv_id = TV_PARSE_FUNC; > + auto_timevar tv (tv_id); > fn = cp_parser_function_definition_after_declarator (parser, > /*inline_p=*/false); > - timevar_pop (tv); > } > > return fn; > @@ -32276,7 +32265,8 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) > static void > cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) > { > - timevar_push (TV_PARSE_INMETH); > + auto_timevar tv (TV_PARSE_INMETH); > + > /* If this member is a template, get the underlying > FUNCTION_DECL. */ > if (DECL_FUNCTION_TEMPLATE_P (member_function)) > @@ -32346,7 +32336,6 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function) > > /* Restore the queue. */ > pop_unparsed_function_queues (parser); > - timevar_pop (TV_PARSE_INMETH); > } > > /* If DECL contains any default args, remember it on the unparsed > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 759f119abc2..2f11ad64bfd 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -9813,10 +9813,12 @@ maybe_get_template_decl_from_type_decl (tree decl) > that we want to avoid. It also causes some problems with argument > coercion (see convert_nontype_argument for more information on this). */ > > -static tree > -lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, > - int entering_scope, tsubst_flags_t complain) > +tree > +lookup_template_class (tree d1, tree arglist, tree in_decl, tree context, > + int entering_scope, tsubst_flags_t complain) > { > + auto_timevar tv (TV_TEMPLATE_INST); > + > tree templ = NULL_TREE, parmlist; > tree t; > spec_entry **slot; > @@ -10354,20 +10356,6 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, > } > } > > -/* Wrapper for lookup_template_class_1. */ > - > -tree > -lookup_template_class (tree d1, tree arglist, tree in_decl, tree context, > - int entering_scope, tsubst_flags_t complain) > -{ > - tree ret; > - timevar_push (TV_TEMPLATE_INST); > - ret = lookup_template_class_1 (d1, arglist, in_decl, context, > - entering_scope, complain); > - timevar_pop (TV_TEMPLATE_INST); > - return ret; > -} > - > /* Return a TEMPLATE_ID_EXPR for the given variable template and ARGLIST. */ > > tree > @@ -11881,9 +11869,11 @@ perform_instantiation_time_access_checks (tree tmpl, tree targs) > } > } > > -static tree > -instantiate_class_template_1 (tree type) > +tree > +instantiate_class_template (tree type) > { > + auto_timevar tv (TV_TEMPLATE_INST); > + > tree templ, args, pattern, t, member; > tree typedecl; > tree pbinfo; > @@ -12405,18 +12395,6 @@ instantiate_class_template_1 (tree type) > return type; > } > > -/* Wrapper for instantiate_class_template_1. */ > - > -tree > -instantiate_class_template (tree type) > -{ > - tree ret; > - timevar_push (TV_TEMPLATE_INST); > - ret = instantiate_class_template_1 (type); > - timevar_pop (TV_TEMPLATE_INST); > - return ret; > -} > - > tree > tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl) > { > @@ -21572,9 +21550,11 @@ recheck_decl_substitution (tree d, tree tmpl, tree args) > /* Instantiate the indicated variable, function, or alias template TMPL with > the template arguments in TARG_PTR. */ > > -static tree > -instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain) > +tree > +instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) > { > + auto_timevar tv (TV_TEMPLATE_INST); > + > tree targ_ptr = orig_args; > tree fndecl; > tree gen_tmpl; > @@ -21746,18 +21726,6 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain) > return fndecl; > } > > -/* Wrapper for instantiate_template_1. */ > - > -tree > -instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) > -{ > - tree ret; > - timevar_push (TV_TEMPLATE_INST); > - ret = instantiate_template_1 (tmpl, orig_args, complain); > - timevar_pop (TV_TEMPLATE_INST); > - return ret; > -} > - > /* Instantiate the alias template TMPL with ARGS. Also push a template > instantiation level, which instantiate_template doesn't do because > functions and variables have sufficient context established by the > @@ -26595,7 +26563,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) > if (! push_tinst_level (d)) > return d; > > - timevar_push (TV_TEMPLATE_INST); > + auto_timevar tv (TV_TEMPLATE_INST); > > /* Set TD to the template whose DECL_TEMPLATE_RESULT is the pattern > for the instantiation. */ > @@ -26761,7 +26729,6 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) > } > > pop_deferring_access_checks (); > - timevar_pop (TV_TEMPLATE_INST); > pop_tinst_level (); > input_location = saved_loc; > cp_unevaluated_operand = saved_unevaluated_operand;