Message ID | 20211018142244.721838-1-jason@redhat.com |
---|---|
State | New |
Headers | show |
Series | [RFA] timevar: Add auto_cond_timevar class | expand |
On Mon, Oct 18, 2021 at 4:23 PM Jason Merrill via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > The auto_timevar sentinel class for starting and stopping timevars was added > in 2014, but doesn't work for the many uses of timevar_cond_start/stop in > the C++ front end. So let's add one that does. > > This allows us to remove a lot of wrapper functions that were just used to > call timevar_cond_stop on all exits from the function. > > Tested x86_64-pc-linux-gnu, OK for trunk? OK. > gcc/ChangeLog: > > * timevar.h (class auto_cond_timevar): New. > > gcc/cp/ChangeLog: > > * call.c > * decl.c > * name-lookup.c: > Use auto_cond_timevar instead of timevar_cond_start/stop. > Remove wrapper functions. > --- > gcc/timevar.h | 46 ++++++++- > gcc/cp/call.c | 106 +++++-------------- > gcc/cp/decl.c | 51 +++------ > gcc/cp/name-lookup.c | 240 ++++++++++++------------------------------- > 4 files changed, 150 insertions(+), 293 deletions(-) > > diff --git a/gcc/timevar.h b/gcc/timevar.h > index 72e31adb9e6..ccaa42e5904 100644 > --- a/gcc/timevar.h > +++ b/gcc/timevar.h > @@ -247,13 +247,53 @@ class auto_timevar > m_timer->pop (m_tv); > } > > - private: > + // Disallow copies. > + auto_timevar (const auto_timevar &) = delete; > > - // Private to disallow copies. > - auto_timevar (const auto_timevar &); > + private: > + timer *m_timer; > + timevar_id_t m_tv; > +}; > + > +// As above, but use cond_start/stop. > +class auto_cond_timevar > +{ > + public: > + auto_cond_timevar (timer *t, timevar_id_t tv) > + : m_timer (t), > + m_tv (tv) > + { > + start (); > + } > + > + explicit auto_cond_timevar (timevar_id_t tv) > + : m_timer (g_timer) > + , m_tv (tv) > + { > + start (); > + } > + > + ~auto_cond_timevar () > + { > + if (m_timer && !already_running) > + m_timer->cond_stop (m_tv); > + } > + > + // Disallow copies. > + auto_cond_timevar (const auto_cond_timevar &) = delete; > + > + private: > + void start() > + { > + if (m_timer) > + already_running = m_timer->cond_start (m_tv); > + else > + already_running = false; > + } > > timer *m_timer; > timevar_id_t m_tv; > + bool already_running; > }; > > extern void print_time (const char *, long); > diff --git a/gcc/cp/call.c b/gcc/cp/call.c > index c5601d96ab8..80e618622fb 100644 > --- a/gcc/cp/call.c > +++ b/gcc/cp/call.c > @@ -4436,7 +4436,7 @@ build_user_type_conversion (tree totype, tree expr, int flags, > struct z_candidate *cand; > tree ret; > > - bool subtime = timevar_cond_start (TV_OVERLOAD); > + auto_cond_timevar tv (TV_OVERLOAD); > cand = build_user_type_conversion_1 (totype, expr, flags, complain); > > if (cand) > @@ -4452,7 +4452,6 @@ build_user_type_conversion (tree totype, tree expr, int flags, > else > ret = NULL_TREE; > > - timevar_cond_stop (TV_OVERLOAD, subtime); > return ret; > } > > @@ -4692,7 +4691,7 @@ perform_overload_resolution (tree fn, > tree explicit_targs; > int template_only; > > - bool subtime = timevar_cond_start (TV_OVERLOAD); > + auto_cond_timevar tv (TV_OVERLOAD); > > explicit_targs = NULL_TREE; > template_only = 0; > @@ -4724,7 +4723,6 @@ perform_overload_resolution (tree fn, > else > cand = NULL; > > - timevar_cond_stop (TV_OVERLOAD, subtime); > return cand; > } > > @@ -4989,8 +4987,8 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args, > > /* Build a new call to operator(). This may change ARGS. */ > > -static tree > -build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) > +tree > +build_op_call (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) > { > struct z_candidate *candidates = 0, *cand; > tree fns, convs, first_mem_arg = NULL_TREE; > @@ -4998,6 +4996,8 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) > tree result = NULL_TREE; > void *p; > > + auto_cond_timevar tv (TV_OVERLOAD); > + > obj = mark_lvalue_use (obj); > > if (error_operand_p (obj)) > @@ -5127,18 +5127,6 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) > return result; > } > > -/* Wrapper for above. */ > - > -tree > -build_op_call (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) > -{ > - tree ret; > - bool subtime = timevar_cond_start (TV_OVERLOAD); > - ret = build_op_call_1 (obj, args, complain); > - timevar_cond_stop (TV_OVERLOAD, subtime); > - return ret; > -} > - > /* Called by op_error to prepare format strings suitable for the error > function. It concatenates a prefix (controlled by MATCH), ERRMSG, > and a suffix (controlled by NTYPES). */ > @@ -5330,10 +5318,10 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain) > /* Implement [expr.cond]. ARG1, ARG2, and ARG3 are the three > arguments to the conditional expression. */ > > -static tree > -build_conditional_expr_1 (const op_location_t &loc, > - tree arg1, tree arg2, tree arg3, > - tsubst_flags_t complain) > +tree > +build_conditional_expr (const op_location_t &loc, > + tree arg1, tree arg2, tree arg3, > + tsubst_flags_t complain) > { > tree arg2_type; > tree arg3_type; > @@ -5345,6 +5333,8 @@ build_conditional_expr_1 (const op_location_t &loc, > void *p; > tree orig_arg2, orig_arg3; > > + auto_cond_timevar tv (TV_OVERLOAD); > + > /* As a G++ extension, the second argument to the conditional can be > omitted. (So that `a ? : c' is roughly equivalent to `a ? a : > c'.) If the second operand is omitted, make sure it is > @@ -5410,8 +5400,8 @@ build_conditional_expr_1 (const op_location_t &loc, > && !VECTOR_TYPE_P (arg3_type)) > { > /* Rely on the error messages of the scalar version. */ > - tree scal = build_conditional_expr_1 (loc, integer_one_node, > - orig_arg2, orig_arg3, complain); > + tree scal = build_conditional_expr (loc, integer_one_node, > + orig_arg2, orig_arg3, complain); > if (scal == error_mark_node) > return error_mark_node; > tree stype = TREE_TYPE (scal); > @@ -5968,20 +5958,6 @@ build_conditional_expr_1 (const op_location_t &loc, > return result; > } > > -/* Wrapper for above. */ > - > -tree > -build_conditional_expr (const op_location_t &loc, > - tree arg1, tree arg2, tree arg3, > - tsubst_flags_t complain) > -{ > - tree ret; > - bool subtime = timevar_cond_start (TV_OVERLOAD); > - ret = build_conditional_expr_1 (loc, arg1, arg2, arg3, complain); > - timevar_cond_stop (TV_OVERLOAD, subtime); > - return ret; > -} > - > /* OPERAND is an operand to an expression. Perform necessary steps > required before using it. If OPERAND is NULL_TREE, NULL_TREE is > returned. */ > @@ -6483,10 +6459,10 @@ add_operator_candidates (z_candidate **candidates, > return NULL_TREE; > } > > -static tree > -build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, > - tree arg1, tree arg2, tree arg3, tree *overload, > - tsubst_flags_t complain) > +tree > +build_new_op (const op_location_t &loc, enum tree_code code, int flags, > + tree arg1, tree arg2, tree arg3, tree *overload, > + tsubst_flags_t complain) > { > struct z_candidate *candidates = 0, *cand; > vec<tree, va_gc> *arglist; > @@ -6500,6 +6476,8 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, > bool strict_p; > bool any_viable_p; > > + auto_cond_timevar tv (TV_OVERLOAD); > + > if (error_operand_p (arg1) > || error_operand_p (arg2) > || error_operand_p (arg3)) > @@ -6635,8 +6613,8 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, > code = PREINCREMENT_EXPR; > else > code = PREDECREMENT_EXPR; > - result = build_new_op_1 (loc, code, flags, arg1, NULL_TREE, > - NULL_TREE, overload, complain); > + result = build_new_op (loc, code, flags, arg1, NULL_TREE, > + NULL_TREE, overload, complain); > break; > > /* The caller will deal with these. */ > @@ -6958,21 +6936,6 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, > return NULL_TREE; > } > > -/* Wrapper for above. */ > - > -tree > -build_new_op (const op_location_t &loc, enum tree_code code, int flags, > - tree arg1, tree arg2, tree arg3, > - tree *overload, tsubst_flags_t complain) > -{ > - tree ret; > - bool subtime = timevar_cond_start (TV_OVERLOAD); > - ret = build_new_op_1 (loc, code, flags, arg1, arg2, arg3, > - overload, complain); > - timevar_cond_stop (TV_OVERLOAD, subtime); > - return ret; > -} > - > /* CALL was returned by some call-building function; extract the actual > CALL_EXPR from any bits that have been tacked on, e.g. by > convert_from_reference. */ > @@ -10670,10 +10633,10 @@ complain_about_no_candidates_for_method_call (tree instance, > be set, upon return, to the function called. ARGS may be NULL. > This may change ARGS. */ > > -static tree > -build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, > - tree conversion_path, int flags, > - tree *fn_p, tsubst_flags_t complain) > +tree > +build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, > + tree conversion_path, int flags, > + tree *fn_p, tsubst_flags_t complain) > { > struct z_candidate *candidates = 0, *cand; > tree explicit_targs = NULL_TREE; > @@ -10693,6 +10656,8 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, > vec<tree, va_gc> *orig_args = NULL; > void *p; > > + auto_cond_timevar tv (TV_OVERLOAD); > + > gcc_assert (instance != NULL_TREE); > > /* We don't know what function we're going to call, yet. */ > @@ -11072,21 +11037,6 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, > return call; > } > > -/* Wrapper for above. */ > - > -tree > -build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, > - tree conversion_path, int flags, > - tree *fn_p, tsubst_flags_t complain) > -{ > - tree ret; > - bool subtime = timevar_cond_start (TV_OVERLOAD); > - ret = build_new_method_call_1 (instance, fns, args, conversion_path, flags, > - fn_p, complain); > - timevar_cond_stop (TV_OVERLOAD, subtime); > - return ret; > -} > - > /* Returns true iff standard conversion sequence ICS1 is a proper > subsequence of ICS2. */ > > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c > index 242429d9ef4..2ff3845dcd4 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -597,7 +597,7 @@ poplevel (int keep, int reverse, int functionbody) > tree decl; > scope_kind kind; > > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > restart: > > block = NULL_TREE; > @@ -829,7 +829,6 @@ poplevel (int keep, int reverse, int functionbody) > if (kind == sk_cleanup) > goto restart; > > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return block; > } > > @@ -908,7 +907,7 @@ static GTY((deletable)) vec<tree, va_gc> *local_entities; > void > determine_local_discriminator (tree decl) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > retrofit_lang_decl (decl); > tree ctx = DECL_CONTEXT (decl); > tree name = (TREE_CODE (decl) == TYPE_DECL > @@ -943,8 +942,6 @@ determine_local_discriminator (tree decl) > local_entities->quick_push (decl); > local_entities->quick_push (name); > } > - > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > } > > > @@ -3277,6 +3274,8 @@ named_label_hash::equal (const value_type entry, compare_type name) > static named_label_entry * > lookup_label_1 (tree id, bool making_local_p) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > /* You can't use labels at global scope. */ > if (current_function_decl == NULL_TREE) > { > @@ -3339,18 +3338,14 @@ lookup_label_1 (tree id, bool making_local_p) > tree > lookup_label (tree id) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > named_label_entry *ent = lookup_label_1 (id, false); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return ent ? ent->label_decl : NULL_TREE; > } > > tree > declare_local_label (tree id) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > named_label_entry *ent = lookup_label_1 (id, true); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return ent ? ent->label_decl : NULL_TREE; > } > > @@ -3681,9 +3676,11 @@ check_omp_return (void) > /* Define a label, specifying the location in the source file. > Return the LABEL_DECL node for the label. */ > > -static tree > -define_label_1 (location_t location, tree name) > +tree > +define_label (location_t location, tree name) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > /* After labels, make any new cleanups in the function go into their > own new (temporary) binding contour. */ > for (cp_binding_level *p = current_binding_level; > @@ -3717,18 +3714,6 @@ define_label_1 (location_t location, tree name) > return decl; > } > > -/* Wrapper for define_label_1. */ > - > -tree > -define_label (location_t location, tree name) > -{ > - bool running = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = define_label_1 (location, name); > - timevar_cond_stop (TV_NAME_LOOKUP, running); > - return ret; > -} > - > - > struct cp_switch > { > cp_binding_level *level; > @@ -15499,13 +15484,15 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, > TEMPLATE_HEADER_P is true when this declaration is preceded by > a set of template parameters. */ > > -static tree > -xref_tag_1 (enum tag_types tag_code, tree name, > - TAG_how how, bool template_header_p) > +tree > +xref_tag (enum tag_types tag_code, tree name, > + TAG_how how, bool template_header_p) > { > enum tree_code code; > tree context = NULL_TREE; > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > gcc_assert (identifier_p (name)); > > switch (tag_code) > @@ -15654,18 +15641,6 @@ xref_tag_1 (enum tag_types tag_code, tree name, > return t; > } > > -/* Wrapper for xref_tag_1. */ > - > -tree > -xref_tag (enum tag_types tag_code, tree name, > - TAG_how how, bool template_header_p) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = xref_tag_1 (tag_code, name, how, template_header_p); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > /* Create the binfo hierarchy for REF with (possibly NULL) base list > BASE_LIST. For each element on BASE_LIST the TREE_PURPOSE is an > access_* node, and the TREE_VALUE is the type of the base-class. > diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c > index c414a1091b4..b4c636d551a 100644 > --- a/gcc/cp/name-lookup.c > +++ b/gcc/cp/name-lookup.c > @@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see > > static cxx_binding *cxx_binding_make (tree value, tree type); > static cp_binding_level *innermost_nonclass_level (void); > -static tree do_pushdecl (tree decl, bool hiding); > static void set_identifier_type_value_with_scope (tree id, tree decl, > cp_binding_level *b); > static name_hint maybe_suggest_missing_std_header (location_t location, > @@ -1725,11 +1724,9 @@ static void diagnose_name_conflict (tree, tree); > tree > lookup_arg_dependent (tree name, tree fns, vec<tree, va_gc> *args) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > name_lookup lookup (name); > - fns = lookup.search_adl (fns, args); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return fns; > + return lookup.search_adl (fns, args); > } > > /* FNS is an overload set of conversion functions. Return the > @@ -2595,8 +2592,10 @@ anticipated_builtin_p (tree ovl) > was successful. */ > > static bool > -supplement_binding_1 (cxx_binding *binding, tree decl) > +supplement_binding (cxx_binding *binding, tree decl) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > tree bval = binding->value; > bool ok = true; > tree target_bval = strip_using_decl (bval); > @@ -2736,18 +2735,6 @@ diagnose_name_conflict (tree decl, tree bval) > inform (location_of (bval), "previous declaration %q#D", bval); > } > > -/* Wrapper for supplement_binding_1. */ > - > -static bool > -supplement_binding (cxx_binding *binding, tree decl) > -{ > - bool ret; > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - ret = supplement_binding_1 (binding, decl); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > /* Replace BINDING's current value on its scope's name list with > NEWVAL. */ > > @@ -3472,7 +3459,7 @@ push_local_extern_decl_alias (tree decl) > /* Expected default linkage is from the namespace. */ > TREE_PUBLIC (alias) = TREE_PUBLIC (ns); > push_nested_namespace (ns); > - alias = do_pushdecl (alias, /* hiding= */true); > + alias = pushdecl (alias, /* hiding= */true); > pop_nested_namespace (ns); > if (VAR_P (decl) && CP_DECL_THREAD_LOCAL_P (decl)) > set_decl_tls_model (alias, DECL_TLS_MODEL (decl)); > @@ -3618,16 +3605,20 @@ check_module_override (tree decl, tree mvec, bool hiding, > > /* Record DECL as belonging to the current lexical scope. Check for > errors (such as an incompatible declaration for the same name > - already seen in the same scope). IS_FRIEND is true if DECL is > - declared as a friend. > + already seen in the same scope). > + > + The new binding is hidden if HIDING is true (an anticipated builtin > + or hidden friend). > > Returns either DECL or an old decl for the same name. If an old > decl is returned, it may have been smashed to agree with what DECL > says. */ > > -static tree > -do_pushdecl (tree decl, bool hiding) > +tree > +pushdecl (tree decl, bool hiding) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > if (decl == error_mark_node) > return error_mark_node; > > @@ -3843,19 +3834,6 @@ do_pushdecl (tree decl, bool hiding) > return decl; > } > > -/* Record a decl-node X as belonging to the current lexical scope. > - The new binding is hidden if HIDING is true (an anticipated builtin > - or hidden friend). */ > - > -tree > -pushdecl (tree x, bool hiding) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = do_pushdecl (x, hiding); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > /* A mergeable entity is being loaded into namespace NS slot NAME. > Create and return the appropriate vector slot for that. Either a > GMF slot or a module-specific one. */ > @@ -4784,7 +4762,7 @@ do_pushdecl_with_scope (tree x, cp_binding_level *level, bool hiding = false) > current_function_decl = NULL_TREE; > b = current_binding_level; > current_binding_level = level; > - x = do_pushdecl (x, hiding); > + x = pushdecl (x, hiding); > current_binding_level = b; > current_function_decl = function_decl; > } > @@ -4797,17 +4775,14 @@ tree > pushdecl_outermost_localscope (tree x) > { > cp_binding_level *b = NULL; > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > > /* Find the scope just inside the function parms. */ > for (cp_binding_level *n = current_binding_level; > n->kind != sk_function_parms; n = b->level_chain) > b = n; > > - tree ret = b ? do_pushdecl_with_scope (x, b) : error_mark_node; > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - > - return ret; > + return b ? do_pushdecl_with_scope (x, b) : error_mark_node; > } > > /* Process a local-scope or namespace-scope using declaration. LOOKUP > @@ -5196,7 +5171,7 @@ poplevel_class (void) > size_t i; > tree shadowed; > > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > gcc_assert (level != 0); > > /* If we're leaving a toplevel class, cache its binding level. */ > @@ -5223,7 +5198,6 @@ poplevel_class (void) > `pushlevel_class' routine. */ > gcc_assert (current_binding_level == level); > leave_scope (); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > } > > /* Set INHERITED_VALUE_BINDING_P on BINDING to true or false, as > @@ -5266,14 +5240,13 @@ bool > pushdecl_class_level (tree x) > { > bool is_valid = true; > - bool subtime; > > /* Do nothing if we're adding to an outer lambda closure type, > outer_binding will add it later if it's needed. */ > if (current_class_type != class_binding_level->this_entity) > return true; > > - subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > /* Get the name of X. */ > tree name = OVL_NAME (x); > > @@ -5313,7 +5286,6 @@ pushdecl_class_level (tree x) > } > input_location = save_location; > } > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return is_valid; > } > > @@ -5359,13 +5331,15 @@ get_class_binding (tree name, cp_binding_level *scope) > /* Make the declaration(s) of X appear in CLASS scope under the name > NAME. Returns true if the binding is valid. */ > > -static bool > -push_class_level_binding_1 (tree name, tree x) > +bool > +push_class_level_binding (tree name, tree x) > { > cxx_binding *binding; > tree decl = x; > bool ok; > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > /* The class_binding_level will be NULL if x is a template > parameter name in a member template. */ > if (!class_binding_level) > @@ -5537,18 +5511,6 @@ push_class_level_binding_1 (tree name, tree x) > return ok; > } > > -/* Wrapper for push_class_level_binding_1. */ > - > -bool > -push_class_level_binding (tree name, tree x) > -{ > - bool ret; > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - ret = push_class_level_binding_1 (name, x); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > /* Process and lookup a using decl SCOPE::lookup.name, filling in > lookup.values & lookup.type. Return a USING_DECL, or NULL_TREE on > failure. */ > @@ -5792,7 +5754,7 @@ do_class_using_decl (tree scope, tree name) > tree > get_namespace_binding (tree ns, tree name) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > if (!ns) > ns = global_namespace; > gcc_checking_assert (!DECL_NAMESPACE_ALIAS (ns)); > @@ -5808,7 +5770,6 @@ get_namespace_binding (tree ns, tree name) > ret = MAYBE_STAT_DECL (ret); > } > > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return ret; > } > > @@ -5819,7 +5780,7 @@ get_namespace_binding (tree ns, tree name) > void > set_global_binding (tree decl) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > > tree *slot = find_namespace_slot (global_namespace, DECL_NAME (decl), true); > > @@ -5829,8 +5790,6 @@ set_global_binding (tree decl) > > /* Force the binding, so compiler internals continue to work. */ > *slot = decl; > - > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > } > > /* Set the context of a declaration to scope. Complain if we are not > @@ -6123,11 +6082,9 @@ do_namespace_alias (tree alias, tree name_space) > tree > pushdecl_namespace_level (tree decl, bool hiding) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree res = do_pushdecl_with_scope (decl, NAMESPACE_LEVEL (current_namespace), > - hiding); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return res; > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + return do_pushdecl_with_scope (decl, NAMESPACE_LEVEL (current_namespace), > + hiding); > } > > /* Wrapper around push_local_binding to push the bindings for > @@ -7690,11 +7647,13 @@ innermost_non_namespace_value (tree name) > WANT can also have LOOK_want::HIDDEN_FRIEND or > LOOK_want::HIDDEN_LAMBDa added to it. */ > > -static tree > -lookup_name_1 (tree name, LOOK_where where, LOOK_want want) > +tree > +lookup_name (tree name, LOOK_where where, LOOK_want want) > { > tree val = NULL_TREE; > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > gcc_checking_assert (unsigned (where) != 0); > /* If we're looking for hidden lambda things, we shouldn't be > looking in namespace scope. */ > @@ -7795,17 +7754,6 @@ lookup_name_1 (tree name, LOOK_where where, LOOK_want want) > return val; > } > > -/* Wrapper for lookup_name_1. */ > - > -tree > -lookup_name (tree name, LOOK_where where, LOOK_want want) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = lookup_name_1 (name, where, want); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > tree > lookup_name (tree name) > { > @@ -7825,9 +7773,11 @@ lookup_name (tree name) > A TYPE_DECL best matching the NAME is returned. Catching error > and issuing diagnostics are caller's responsibility. */ > > -static tree > -lookup_elaborated_type_1 (tree name, TAG_how how) > +tree > +lookup_elaborated_type (tree name, TAG_how how) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > cp_binding_level *b = current_binding_level; > > if (b->kind != sk_namespace) > @@ -8011,17 +7961,6 @@ lookup_elaborated_type_1 (tree name, TAG_how how) > return NULL_TREE; > } > > -/* Wrapper for lookup_type_scope_1. */ > - > -tree > -lookup_elaborated_type (tree name, TAG_how how) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = lookup_elaborated_type_1 (name, how); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > /* The type TYPE is being declared. If it is a class template, or a > specialization of a class template, do any processing required and > perform error-checking. If IS_FRIEND is nonzero, this TYPE is > @@ -8099,13 +8038,15 @@ maybe_process_template_type_declaration (tree type, int is_friend, > > Returns TYPE upon success and ERROR_MARK_NODE otherwise. */ > > -static tree > -do_pushtag (tree name, tree type, TAG_how how) > +tree > +pushtag (tree name, tree type, TAG_how how) > { > tree decl; > > gcc_assert (identifier_p (name)); > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > cp_binding_level *b = current_binding_level; > while (true) > { > @@ -8249,18 +8190,6 @@ do_pushtag (tree name, tree type, TAG_how how) > > return type; > } > - > -/* Wrapper for do_pushtag. */ > - > -tree > -pushtag (tree name, tree type, TAG_how how) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - tree ret = do_pushtag (name, type, how); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > - return ret; > -} > - > > /* Subroutines for reverting temporarily to top-level for instantiation > of templates and such. We actually need to clear out the class- and > @@ -8309,7 +8238,7 @@ store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings) > tree t, id; > size_t i; > > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > for (t = names; t; t = TREE_CHAIN (t)) > { > if (TREE_CODE (t) == TREE_LIST) > @@ -8331,7 +8260,6 @@ store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings) > } > bindings_need_stored.truncate (0); > } > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > } > > /* Like store_bindings, but NAMES is a vector of cp_class_binding > @@ -8362,8 +8290,8 @@ store_class_bindings (vec<cp_class_binding, va_gc> *names, > > static GTY((deletable)) struct saved_scope *free_saved_scope; > > -static void > -do_push_to_top_level (void) > +void > +push_to_top_level (void) > { > struct saved_scope *s; > cp_binding_level *b; > @@ -8371,6 +8299,8 @@ do_push_to_top_level (void) > size_t i; > bool need_pop; > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > /* Reuse or create a new structure for this saved scope. */ > if (free_saved_scope != NULL) > { > @@ -8448,13 +8378,15 @@ do_push_to_top_level (void) > suppress_location_wrappers = 0; > } > > -static void > -do_pop_from_top_level (void) > +void > +pop_from_top_level (void) > { > struct saved_scope *s = scope_chain; > cxx_saved_binding *saved; > size_t i; > > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + > /* Clear out class-level bindings cache. */ > if (previous_class_level) > invalidate_class_lookup_cache (); > @@ -8489,14 +8421,15 @@ do_pop_from_top_level (void) > /* Push into the scope of the namespace NS, even if it is deeply > nested within another namespace. */ > > -static void > -do_push_nested_namespace (tree ns) > +void > +push_nested_namespace (tree ns) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > if (ns == global_namespace) > - do_push_to_top_level (); > + push_to_top_level (); > else > { > - do_push_nested_namespace (CP_DECL_CONTEXT (ns)); > + push_nested_namespace (CP_DECL_CONTEXT (ns)); > resume_scope (NAMESPACE_LEVEL (ns)); > current_namespace = ns; > } > @@ -8505,9 +8438,10 @@ do_push_nested_namespace (tree ns) > /* Pop back from the scope of the namespace NS, which was previously > entered with push_nested_namespace. */ > > -static void > -do_pop_nested_namespace (tree ns) > +void > +pop_nested_namespace (tree ns) > { > + auto_cond_timevar tv (TV_NAME_LOOKUP); > while (ns != global_namespace) > { > ns = CP_DECL_CONTEXT (ns); > @@ -8515,7 +8449,7 @@ do_pop_nested_namespace (tree ns) > leave_scope (); > } > > - do_pop_from_top_level (); > + pop_from_top_level (); > } > > /* Add TARGET to USINGS, if it does not already exist there. We used > @@ -8595,13 +8529,12 @@ finish_using_directive (tree target, tree attribs) > tree > pushdecl_top_level (tree x) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - do_push_to_top_level (); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + push_to_top_level (); > gcc_checking_assert (!DECL_CONTEXT (x)); > DECL_CONTEXT (x) = FROB_CONTEXT (global_namespace); > x = pushdecl_namespace_level (x); > - do_pop_from_top_level (); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > + pop_from_top_level (); > return x; > } > > @@ -8611,14 +8544,13 @@ pushdecl_top_level (tree x) > tree > pushdecl_top_level_and_finish (tree x, tree init) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - do_push_to_top_level (); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > + push_to_top_level (); > gcc_checking_assert (!DECL_CONTEXT (x)); > DECL_CONTEXT (x) = FROB_CONTEXT (global_namespace); > x = pushdecl_namespace_level (x); > cp_finish_decl (x, init, false, NULL_TREE, 0); > - do_pop_from_top_level (); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > + pop_from_top_level (); > return x; > } > > @@ -8728,7 +8660,7 @@ make_namespace_finish (tree ns, tree *slot, bool from_import = false) > int > push_namespace (tree name, bool make_inline) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > int count = 0; > > /* We should not get here if the global_namespace is not yet constructed > @@ -8875,7 +8807,6 @@ push_namespace (tree name, bool make_inline) > count++; > } > > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > return count; > } > > @@ -8884,14 +8815,12 @@ push_namespace (tree name, bool make_inline) > void > pop_namespace (void) > { > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > + auto_cond_timevar tv (TV_NAME_LOOKUP); > > gcc_assert (current_namespace != global_namespace); > current_namespace = CP_DECL_CONTEXT (current_namespace); > /* The binding level is not popped, as it might be re-opened later. */ > leave_scope (); > - > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > } > > /* An IMPORT is an import that is defining namespace NAME inside CTX. Find or > @@ -8958,43 +8887,6 @@ add_imported_namespace (tree ctx, tree name, location_t loc, unsigned import, > return decl; > } > > -/* External entry points for do_{push_to/pop_from}_top_level. */ > - > -void > -push_to_top_level (void) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - do_push_to_top_level (); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > -} > - > -void > -pop_from_top_level (void) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - do_pop_from_top_level (); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > -} > - > -/* External entry points for do_{push,pop}_nested_namespace. */ > - > -void > -push_nested_namespace (tree ns) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - do_push_nested_namespace (ns); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > -} > - > -void > -pop_nested_namespace (tree ns) > -{ > - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); > - gcc_assert (current_namespace == ns); > - do_pop_nested_namespace (ns); > - timevar_cond_stop (TV_NAME_LOOKUP, subtime); > -} > - > /* Pop off extraneous binding levels left over due to syntax errors. > We don't pop past namespaces, as they might be valid. */ > > > base-commit: 582d43a48cb28e6ed36ea6388ca92f3d5d786a26 > -- > 2.27.0 >
diff --git a/gcc/timevar.h b/gcc/timevar.h index 72e31adb9e6..ccaa42e5904 100644 --- a/gcc/timevar.h +++ b/gcc/timevar.h @@ -247,13 +247,53 @@ class auto_timevar m_timer->pop (m_tv); } - private: + // Disallow copies. + auto_timevar (const auto_timevar &) = delete; - // Private to disallow copies. - auto_timevar (const auto_timevar &); + private: + timer *m_timer; + timevar_id_t m_tv; +}; + +// As above, but use cond_start/stop. +class auto_cond_timevar +{ + public: + auto_cond_timevar (timer *t, timevar_id_t tv) + : m_timer (t), + m_tv (tv) + { + start (); + } + + explicit auto_cond_timevar (timevar_id_t tv) + : m_timer (g_timer) + , m_tv (tv) + { + start (); + } + + ~auto_cond_timevar () + { + if (m_timer && !already_running) + m_timer->cond_stop (m_tv); + } + + // Disallow copies. + auto_cond_timevar (const auto_cond_timevar &) = delete; + + private: + void start() + { + if (m_timer) + already_running = m_timer->cond_start (m_tv); + else + already_running = false; + } timer *m_timer; timevar_id_t m_tv; + bool already_running; }; extern void print_time (const char *, long); diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c5601d96ab8..80e618622fb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4436,7 +4436,7 @@ build_user_type_conversion (tree totype, tree expr, int flags, struct z_candidate *cand; tree ret; - bool subtime = timevar_cond_start (TV_OVERLOAD); + auto_cond_timevar tv (TV_OVERLOAD); cand = build_user_type_conversion_1 (totype, expr, flags, complain); if (cand) @@ -4452,7 +4452,6 @@ build_user_type_conversion (tree totype, tree expr, int flags, else ret = NULL_TREE; - timevar_cond_stop (TV_OVERLOAD, subtime); return ret; } @@ -4692,7 +4691,7 @@ perform_overload_resolution (tree fn, tree explicit_targs; int template_only; - bool subtime = timevar_cond_start (TV_OVERLOAD); + auto_cond_timevar tv (TV_OVERLOAD); explicit_targs = NULL_TREE; template_only = 0; @@ -4724,7 +4723,6 @@ perform_overload_resolution (tree fn, else cand = NULL; - timevar_cond_stop (TV_OVERLOAD, subtime); return cand; } @@ -4989,8 +4987,8 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args, /* Build a new call to operator(). This may change ARGS. */ -static tree -build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) +tree +build_op_call (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) { struct z_candidate *candidates = 0, *cand; tree fns, convs, first_mem_arg = NULL_TREE; @@ -4998,6 +4996,8 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) tree result = NULL_TREE; void *p; + auto_cond_timevar tv (TV_OVERLOAD); + obj = mark_lvalue_use (obj); if (error_operand_p (obj)) @@ -5127,18 +5127,6 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) return result; } -/* Wrapper for above. */ - -tree -build_op_call (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) -{ - tree ret; - bool subtime = timevar_cond_start (TV_OVERLOAD); - ret = build_op_call_1 (obj, args, complain); - timevar_cond_stop (TV_OVERLOAD, subtime); - return ret; -} - /* Called by op_error to prepare format strings suitable for the error function. It concatenates a prefix (controlled by MATCH), ERRMSG, and a suffix (controlled by NTYPES). */ @@ -5330,10 +5318,10 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain) /* Implement [expr.cond]. ARG1, ARG2, and ARG3 are the three arguments to the conditional expression. */ -static tree -build_conditional_expr_1 (const op_location_t &loc, - tree arg1, tree arg2, tree arg3, - tsubst_flags_t complain) +tree +build_conditional_expr (const op_location_t &loc, + tree arg1, tree arg2, tree arg3, + tsubst_flags_t complain) { tree arg2_type; tree arg3_type; @@ -5345,6 +5333,8 @@ build_conditional_expr_1 (const op_location_t &loc, void *p; tree orig_arg2, orig_arg3; + auto_cond_timevar tv (TV_OVERLOAD); + /* As a G++ extension, the second argument to the conditional can be omitted. (So that `a ? : c' is roughly equivalent to `a ? a : c'.) If the second operand is omitted, make sure it is @@ -5410,8 +5400,8 @@ build_conditional_expr_1 (const op_location_t &loc, && !VECTOR_TYPE_P (arg3_type)) { /* Rely on the error messages of the scalar version. */ - tree scal = build_conditional_expr_1 (loc, integer_one_node, - orig_arg2, orig_arg3, complain); + tree scal = build_conditional_expr (loc, integer_one_node, + orig_arg2, orig_arg3, complain); if (scal == error_mark_node) return error_mark_node; tree stype = TREE_TYPE (scal); @@ -5968,20 +5958,6 @@ build_conditional_expr_1 (const op_location_t &loc, return result; } -/* Wrapper for above. */ - -tree -build_conditional_expr (const op_location_t &loc, - tree arg1, tree arg2, tree arg3, - tsubst_flags_t complain) -{ - tree ret; - bool subtime = timevar_cond_start (TV_OVERLOAD); - ret = build_conditional_expr_1 (loc, arg1, arg2, arg3, complain); - timevar_cond_stop (TV_OVERLOAD, subtime); - return ret; -} - /* OPERAND is an operand to an expression. Perform necessary steps required before using it. If OPERAND is NULL_TREE, NULL_TREE is returned. */ @@ -6483,10 +6459,10 @@ add_operator_candidates (z_candidate **candidates, return NULL_TREE; } -static tree -build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, - tree arg1, tree arg2, tree arg3, tree *overload, - tsubst_flags_t complain) +tree +build_new_op (const op_location_t &loc, enum tree_code code, int flags, + tree arg1, tree arg2, tree arg3, tree *overload, + tsubst_flags_t complain) { struct z_candidate *candidates = 0, *cand; vec<tree, va_gc> *arglist; @@ -6500,6 +6476,8 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, bool strict_p; bool any_viable_p; + auto_cond_timevar tv (TV_OVERLOAD); + if (error_operand_p (arg1) || error_operand_p (arg2) || error_operand_p (arg3)) @@ -6635,8 +6613,8 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, code = PREINCREMENT_EXPR; else code = PREDECREMENT_EXPR; - result = build_new_op_1 (loc, code, flags, arg1, NULL_TREE, - NULL_TREE, overload, complain); + result = build_new_op (loc, code, flags, arg1, NULL_TREE, + NULL_TREE, overload, complain); break; /* The caller will deal with these. */ @@ -6958,21 +6936,6 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, return NULL_TREE; } -/* Wrapper for above. */ - -tree -build_new_op (const op_location_t &loc, enum tree_code code, int flags, - tree arg1, tree arg2, tree arg3, - tree *overload, tsubst_flags_t complain) -{ - tree ret; - bool subtime = timevar_cond_start (TV_OVERLOAD); - ret = build_new_op_1 (loc, code, flags, arg1, arg2, arg3, - overload, complain); - timevar_cond_stop (TV_OVERLOAD, subtime); - return ret; -} - /* CALL was returned by some call-building function; extract the actual CALL_EXPR from any bits that have been tacked on, e.g. by convert_from_reference. */ @@ -10670,10 +10633,10 @@ complain_about_no_candidates_for_method_call (tree instance, be set, upon return, to the function called. ARGS may be NULL. This may change ARGS. */ -static tree -build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, - tree conversion_path, int flags, - tree *fn_p, tsubst_flags_t complain) +tree +build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, + tree conversion_path, int flags, + tree *fn_p, tsubst_flags_t complain) { struct z_candidate *candidates = 0, *cand; tree explicit_targs = NULL_TREE; @@ -10693,6 +10656,8 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, vec<tree, va_gc> *orig_args = NULL; void *p; + auto_cond_timevar tv (TV_OVERLOAD); + gcc_assert (instance != NULL_TREE); /* We don't know what function we're going to call, yet. */ @@ -11072,21 +11037,6 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, return call; } -/* Wrapper for above. */ - -tree -build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, - tree conversion_path, int flags, - tree *fn_p, tsubst_flags_t complain) -{ - tree ret; - bool subtime = timevar_cond_start (TV_OVERLOAD); - ret = build_new_method_call_1 (instance, fns, args, conversion_path, flags, - fn_p, complain); - timevar_cond_stop (TV_OVERLOAD, subtime); - return ret; -} - /* Returns true iff standard conversion sequence ICS1 is a proper subsequence of ICS2. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 242429d9ef4..2ff3845dcd4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -597,7 +597,7 @@ poplevel (int keep, int reverse, int functionbody) tree decl; scope_kind kind; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); restart: block = NULL_TREE; @@ -829,7 +829,6 @@ poplevel (int keep, int reverse, int functionbody) if (kind == sk_cleanup) goto restart; - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return block; } @@ -908,7 +907,7 @@ static GTY((deletable)) vec<tree, va_gc> *local_entities; void determine_local_discriminator (tree decl) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); retrofit_lang_decl (decl); tree ctx = DECL_CONTEXT (decl); tree name = (TREE_CODE (decl) == TYPE_DECL @@ -943,8 +942,6 @@ determine_local_discriminator (tree decl) local_entities->quick_push (decl); local_entities->quick_push (name); } - - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } @@ -3277,6 +3274,8 @@ named_label_hash::equal (const value_type entry, compare_type name) static named_label_entry * lookup_label_1 (tree id, bool making_local_p) { + auto_cond_timevar tv (TV_NAME_LOOKUP); + /* You can't use labels at global scope. */ if (current_function_decl == NULL_TREE) { @@ -3339,18 +3338,14 @@ lookup_label_1 (tree id, bool making_local_p) tree lookup_label (tree id) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); named_label_entry *ent = lookup_label_1 (id, false); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ent ? ent->label_decl : NULL_TREE; } tree declare_local_label (tree id) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); named_label_entry *ent = lookup_label_1 (id, true); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ent ? ent->label_decl : NULL_TREE; } @@ -3681,9 +3676,11 @@ check_omp_return (void) /* Define a label, specifying the location in the source file. Return the LABEL_DECL node for the label. */ -static tree -define_label_1 (location_t location, tree name) +tree +define_label (location_t location, tree name) { + auto_cond_timevar tv (TV_NAME_LOOKUP); + /* After labels, make any new cleanups in the function go into their own new (temporary) binding contour. */ for (cp_binding_level *p = current_binding_level; @@ -3717,18 +3714,6 @@ define_label_1 (location_t location, tree name) return decl; } -/* Wrapper for define_label_1. */ - -tree -define_label (location_t location, tree name) -{ - bool running = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = define_label_1 (location, name); - timevar_cond_stop (TV_NAME_LOOKUP, running); - return ret; -} - - struct cp_switch { cp_binding_level *level; @@ -15499,13 +15484,15 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, TEMPLATE_HEADER_P is true when this declaration is preceded by a set of template parameters. */ -static tree -xref_tag_1 (enum tag_types tag_code, tree name, - TAG_how how, bool template_header_p) +tree +xref_tag (enum tag_types tag_code, tree name, + TAG_how how, bool template_header_p) { enum tree_code code; tree context = NULL_TREE; + auto_cond_timevar tv (TV_NAME_LOOKUP); + gcc_assert (identifier_p (name)); switch (tag_code) @@ -15654,18 +15641,6 @@ xref_tag_1 (enum tag_types tag_code, tree name, return t; } -/* Wrapper for xref_tag_1. */ - -tree -xref_tag (enum tag_types tag_code, tree name, - TAG_how how, bool template_header_p) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = xref_tag_1 (tag_code, name, how, template_header_p); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* Create the binfo hierarchy for REF with (possibly NULL) base list BASE_LIST. For each element on BASE_LIST the TREE_PURPOSE is an access_* node, and the TREE_VALUE is the type of the base-class. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index c414a1091b4..b4c636d551a 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see static cxx_binding *cxx_binding_make (tree value, tree type); static cp_binding_level *innermost_nonclass_level (void); -static tree do_pushdecl (tree decl, bool hiding); static void set_identifier_type_value_with_scope (tree id, tree decl, cp_binding_level *b); static name_hint maybe_suggest_missing_std_header (location_t location, @@ -1725,11 +1724,9 @@ static void diagnose_name_conflict (tree, tree); tree lookup_arg_dependent (tree name, tree fns, vec<tree, va_gc> *args) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); name_lookup lookup (name); - fns = lookup.search_adl (fns, args); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return fns; + return lookup.search_adl (fns, args); } /* FNS is an overload set of conversion functions. Return the @@ -2595,8 +2592,10 @@ anticipated_builtin_p (tree ovl) was successful. */ static bool -supplement_binding_1 (cxx_binding *binding, tree decl) +supplement_binding (cxx_binding *binding, tree decl) { + auto_cond_timevar tv (TV_NAME_LOOKUP); + tree bval = binding->value; bool ok = true; tree target_bval = strip_using_decl (bval); @@ -2736,18 +2735,6 @@ diagnose_name_conflict (tree decl, tree bval) inform (location_of (bval), "previous declaration %q#D", bval); } -/* Wrapper for supplement_binding_1. */ - -static bool -supplement_binding (cxx_binding *binding, tree decl) -{ - bool ret; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - ret = supplement_binding_1 (binding, decl); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* Replace BINDING's current value on its scope's name list with NEWVAL. */ @@ -3472,7 +3459,7 @@ push_local_extern_decl_alias (tree decl) /* Expected default linkage is from the namespace. */ TREE_PUBLIC (alias) = TREE_PUBLIC (ns); push_nested_namespace (ns); - alias = do_pushdecl (alias, /* hiding= */true); + alias = pushdecl (alias, /* hiding= */true); pop_nested_namespace (ns); if (VAR_P (decl) && CP_DECL_THREAD_LOCAL_P (decl)) set_decl_tls_model (alias, DECL_TLS_MODEL (decl)); @@ -3618,16 +3605,20 @@ check_module_override (tree decl, tree mvec, bool hiding, /* Record DECL as belonging to the current lexical scope. Check for errors (such as an incompatible declaration for the same name - already seen in the same scope). IS_FRIEND is true if DECL is - declared as a friend. + already seen in the same scope). + + The new binding is hidden if HIDING is true (an anticipated builtin + or hidden friend). Returns either DECL or an old decl for the same name. If an old decl is returned, it may have been smashed to agree with what DECL says. */ -static tree -do_pushdecl (tree decl, bool hiding) +tree +pushdecl (tree decl, bool hiding) { + auto_cond_timevar tv (TV_NAME_LOOKUP); + if (decl == error_mark_node) return error_mark_node; @@ -3843,19 +3834,6 @@ do_pushdecl (tree decl, bool hiding) return decl; } -/* Record a decl-node X as belonging to the current lexical scope. - The new binding is hidden if HIDING is true (an anticipated builtin - or hidden friend). */ - -tree -pushdecl (tree x, bool hiding) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = do_pushdecl (x, hiding); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* A mergeable entity is being loaded into namespace NS slot NAME. Create and return the appropriate vector slot for that. Either a GMF slot or a module-specific one. */ @@ -4784,7 +4762,7 @@ do_pushdecl_with_scope (tree x, cp_binding_level *level, bool hiding = false) current_function_decl = NULL_TREE; b = current_binding_level; current_binding_level = level; - x = do_pushdecl (x, hiding); + x = pushdecl (x, hiding); current_binding_level = b; current_function_decl = function_decl; } @@ -4797,17 +4775,14 @@ tree pushdecl_outermost_localscope (tree x) { cp_binding_level *b = NULL; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); /* Find the scope just inside the function parms. */ for (cp_binding_level *n = current_binding_level; n->kind != sk_function_parms; n = b->level_chain) b = n; - tree ret = b ? do_pushdecl_with_scope (x, b) : error_mark_node; - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - - return ret; + return b ? do_pushdecl_with_scope (x, b) : error_mark_node; } /* Process a local-scope or namespace-scope using declaration. LOOKUP @@ -5196,7 +5171,7 @@ poplevel_class (void) size_t i; tree shadowed; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); gcc_assert (level != 0); /* If we're leaving a toplevel class, cache its binding level. */ @@ -5223,7 +5198,6 @@ poplevel_class (void) `pushlevel_class' routine. */ gcc_assert (current_binding_level == level); leave_scope (); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } /* Set INHERITED_VALUE_BINDING_P on BINDING to true or false, as @@ -5266,14 +5240,13 @@ bool pushdecl_class_level (tree x) { bool is_valid = true; - bool subtime; /* Do nothing if we're adding to an outer lambda closure type, outer_binding will add it later if it's needed. */ if (current_class_type != class_binding_level->this_entity) return true; - subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); /* Get the name of X. */ tree name = OVL_NAME (x); @@ -5313,7 +5286,6 @@ pushdecl_class_level (tree x) } input_location = save_location; } - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return is_valid; } @@ -5359,13 +5331,15 @@ get_class_binding (tree name, cp_binding_level *scope) /* Make the declaration(s) of X appear in CLASS scope under the name NAME. Returns true if the binding is valid. */ -static bool -push_class_level_binding_1 (tree name, tree x) +bool +push_class_level_binding (tree name, tree x) { cxx_binding *binding; tree decl = x; bool ok; + auto_cond_timevar tv (TV_NAME_LOOKUP); + /* The class_binding_level will be NULL if x is a template parameter name in a member template. */ if (!class_binding_level) @@ -5537,18 +5511,6 @@ push_class_level_binding_1 (tree name, tree x) return ok; } -/* Wrapper for push_class_level_binding_1. */ - -bool -push_class_level_binding (tree name, tree x) -{ - bool ret; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - ret = push_class_level_binding_1 (name, x); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* Process and lookup a using decl SCOPE::lookup.name, filling in lookup.values & lookup.type. Return a USING_DECL, or NULL_TREE on failure. */ @@ -5792,7 +5754,7 @@ do_class_using_decl (tree scope, tree name) tree get_namespace_binding (tree ns, tree name) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); if (!ns) ns = global_namespace; gcc_checking_assert (!DECL_NAMESPACE_ALIAS (ns)); @@ -5808,7 +5770,6 @@ get_namespace_binding (tree ns, tree name) ret = MAYBE_STAT_DECL (ret); } - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } @@ -5819,7 +5780,7 @@ get_namespace_binding (tree ns, tree name) void set_global_binding (tree decl) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); tree *slot = find_namespace_slot (global_namespace, DECL_NAME (decl), true); @@ -5829,8 +5790,6 @@ set_global_binding (tree decl) /* Force the binding, so compiler internals continue to work. */ *slot = decl; - - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } /* Set the context of a declaration to scope. Complain if we are not @@ -6123,11 +6082,9 @@ do_namespace_alias (tree alias, tree name_space) tree pushdecl_namespace_level (tree decl, bool hiding) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree res = do_pushdecl_with_scope (decl, NAMESPACE_LEVEL (current_namespace), - hiding); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return res; + auto_cond_timevar tv (TV_NAME_LOOKUP); + return do_pushdecl_with_scope (decl, NAMESPACE_LEVEL (current_namespace), + hiding); } /* Wrapper around push_local_binding to push the bindings for @@ -7690,11 +7647,13 @@ innermost_non_namespace_value (tree name) WANT can also have LOOK_want::HIDDEN_FRIEND or LOOK_want::HIDDEN_LAMBDa added to it. */ -static tree -lookup_name_1 (tree name, LOOK_where where, LOOK_want want) +tree +lookup_name (tree name, LOOK_where where, LOOK_want want) { tree val = NULL_TREE; + auto_cond_timevar tv (TV_NAME_LOOKUP); + gcc_checking_assert (unsigned (where) != 0); /* If we're looking for hidden lambda things, we shouldn't be looking in namespace scope. */ @@ -7795,17 +7754,6 @@ lookup_name_1 (tree name, LOOK_where where, LOOK_want want) return val; } -/* Wrapper for lookup_name_1. */ - -tree -lookup_name (tree name, LOOK_where where, LOOK_want want) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = lookup_name_1 (name, where, want); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - tree lookup_name (tree name) { @@ -7825,9 +7773,11 @@ lookup_name (tree name) A TYPE_DECL best matching the NAME is returned. Catching error and issuing diagnostics are caller's responsibility. */ -static tree -lookup_elaborated_type_1 (tree name, TAG_how how) +tree +lookup_elaborated_type (tree name, TAG_how how) { + auto_cond_timevar tv (TV_NAME_LOOKUP); + cp_binding_level *b = current_binding_level; if (b->kind != sk_namespace) @@ -8011,17 +7961,6 @@ lookup_elaborated_type_1 (tree name, TAG_how how) return NULL_TREE; } -/* Wrapper for lookup_type_scope_1. */ - -tree -lookup_elaborated_type (tree name, TAG_how how) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = lookup_elaborated_type_1 (name, how); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* The type TYPE is being declared. If it is a class template, or a specialization of a class template, do any processing required and perform error-checking. If IS_FRIEND is nonzero, this TYPE is @@ -8099,13 +8038,15 @@ maybe_process_template_type_declaration (tree type, int is_friend, Returns TYPE upon success and ERROR_MARK_NODE otherwise. */ -static tree -do_pushtag (tree name, tree type, TAG_how how) +tree +pushtag (tree name, tree type, TAG_how how) { tree decl; gcc_assert (identifier_p (name)); + auto_cond_timevar tv (TV_NAME_LOOKUP); + cp_binding_level *b = current_binding_level; while (true) { @@ -8249,18 +8190,6 @@ do_pushtag (tree name, tree type, TAG_how how) return type; } - -/* Wrapper for do_pushtag. */ - -tree -pushtag (tree name, tree type, TAG_how how) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = do_pushtag (name, type, how); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); - return ret; -} - /* Subroutines for reverting temporarily to top-level for instantiation of templates and such. We actually need to clear out the class- and @@ -8309,7 +8238,7 @@ store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings) tree t, id; size_t i; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); for (t = names; t; t = TREE_CHAIN (t)) { if (TREE_CODE (t) == TREE_LIST) @@ -8331,7 +8260,6 @@ store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings) } bindings_need_stored.truncate (0); } - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } /* Like store_bindings, but NAMES is a vector of cp_class_binding @@ -8362,8 +8290,8 @@ store_class_bindings (vec<cp_class_binding, va_gc> *names, static GTY((deletable)) struct saved_scope *free_saved_scope; -static void -do_push_to_top_level (void) +void +push_to_top_level (void) { struct saved_scope *s; cp_binding_level *b; @@ -8371,6 +8299,8 @@ do_push_to_top_level (void) size_t i; bool need_pop; + auto_cond_timevar tv (TV_NAME_LOOKUP); + /* Reuse or create a new structure for this saved scope. */ if (free_saved_scope != NULL) { @@ -8448,13 +8378,15 @@ do_push_to_top_level (void) suppress_location_wrappers = 0; } -static void -do_pop_from_top_level (void) +void +pop_from_top_level (void) { struct saved_scope *s = scope_chain; cxx_saved_binding *saved; size_t i; + auto_cond_timevar tv (TV_NAME_LOOKUP); + /* Clear out class-level bindings cache. */ if (previous_class_level) invalidate_class_lookup_cache (); @@ -8489,14 +8421,15 @@ do_pop_from_top_level (void) /* Push into the scope of the namespace NS, even if it is deeply nested within another namespace. */ -static void -do_push_nested_namespace (tree ns) +void +push_nested_namespace (tree ns) { + auto_cond_timevar tv (TV_NAME_LOOKUP); if (ns == global_namespace) - do_push_to_top_level (); + push_to_top_level (); else { - do_push_nested_namespace (CP_DECL_CONTEXT (ns)); + push_nested_namespace (CP_DECL_CONTEXT (ns)); resume_scope (NAMESPACE_LEVEL (ns)); current_namespace = ns; } @@ -8505,9 +8438,10 @@ do_push_nested_namespace (tree ns) /* Pop back from the scope of the namespace NS, which was previously entered with push_nested_namespace. */ -static void -do_pop_nested_namespace (tree ns) +void +pop_nested_namespace (tree ns) { + auto_cond_timevar tv (TV_NAME_LOOKUP); while (ns != global_namespace) { ns = CP_DECL_CONTEXT (ns); @@ -8515,7 +8449,7 @@ do_pop_nested_namespace (tree ns) leave_scope (); } - do_pop_from_top_level (); + pop_from_top_level (); } /* Add TARGET to USINGS, if it does not already exist there. We used @@ -8595,13 +8529,12 @@ finish_using_directive (tree target, tree attribs) tree pushdecl_top_level (tree x) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - do_push_to_top_level (); + auto_cond_timevar tv (TV_NAME_LOOKUP); + push_to_top_level (); gcc_checking_assert (!DECL_CONTEXT (x)); DECL_CONTEXT (x) = FROB_CONTEXT (global_namespace); x = pushdecl_namespace_level (x); - do_pop_from_top_level (); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); + pop_from_top_level (); return x; } @@ -8611,14 +8544,13 @@ pushdecl_top_level (tree x) tree pushdecl_top_level_and_finish (tree x, tree init) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - do_push_to_top_level (); + auto_cond_timevar tv (TV_NAME_LOOKUP); + push_to_top_level (); gcc_checking_assert (!DECL_CONTEXT (x)); DECL_CONTEXT (x) = FROB_CONTEXT (global_namespace); x = pushdecl_namespace_level (x); cp_finish_decl (x, init, false, NULL_TREE, 0); - do_pop_from_top_level (); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); + pop_from_top_level (); return x; } @@ -8728,7 +8660,7 @@ make_namespace_finish (tree ns, tree *slot, bool from_import = false) int push_namespace (tree name, bool make_inline) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); int count = 0; /* We should not get here if the global_namespace is not yet constructed @@ -8875,7 +8807,6 @@ push_namespace (tree name, bool make_inline) count++; } - timevar_cond_stop (TV_NAME_LOOKUP, subtime); return count; } @@ -8884,14 +8815,12 @@ push_namespace (tree name, bool make_inline) void pop_namespace (void) { - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); gcc_assert (current_namespace != global_namespace); current_namespace = CP_DECL_CONTEXT (current_namespace); /* The binding level is not popped, as it might be re-opened later. */ leave_scope (); - - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } /* An IMPORT is an import that is defining namespace NAME inside CTX. Find or @@ -8958,43 +8887,6 @@ add_imported_namespace (tree ctx, tree name, location_t loc, unsigned import, return decl; } -/* External entry points for do_{push_to/pop_from}_top_level. */ - -void -push_to_top_level (void) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - do_push_to_top_level (); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); -} - -void -pop_from_top_level (void) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - do_pop_from_top_level (); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); -} - -/* External entry points for do_{push,pop}_nested_namespace. */ - -void -push_nested_namespace (tree ns) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - do_push_nested_namespace (ns); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); -} - -void -pop_nested_namespace (tree ns) -{ - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - gcc_assert (current_namespace == ns); - do_pop_nested_namespace (ns); - timevar_cond_stop (TV_NAME_LOOKUP, subtime); -} - /* Pop off extraneous binding levels left over due to syntax errors. We don't pop past namespaces, as they might be valid. */