This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to cp/decl.c: Timing name lookup
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: 13 Feb 2003 05:59:44 +0100
- Subject: Re: C++ PATCH to cp/decl.c: Timing name lookup
- Organization: Integrable Solutions
- References: <m31y2edhs4.fsf@dromion.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
[...]
| Bootstrapped and tested on an i686-pc-linux-gnu. A slightly modified
| version will be applied to mainline.
Like this
-- Gaby
2003-02-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
* timevar.h (POP_TIMEVAR_AND_RETURN): New macro.
cp/
2003-02-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
* decl.c: Include "timevar.h".
(poplevel): Time name lookup.
(find_binding): Likewise.
(push_namespace): Likewise.
(pop_nested_namespace): Likewise.
(store_bindings): Likewise.
(maybe_push_to_top_level): Likewise.
(pop_from_top_level): Likewise.
(push_local_name): Likewise.
(pushtag): Likewise.
(pushdecl): Likewise.
(pushdecl_with_scope): Likewise.
(pushdecl_namespace_level): Likewise.
(pushdecl_top_level): Likewise.
(pushdecl_class_level): Likewise.
(push_class_level_binding): Likewise.
(push_using_decl): Likewise.
(push_using_directive): Likewise.
(push_overloaded_decl): Likewise.
(lookup_label): Likewise.
(define_label): Likewise.
(lookup_tag): Likewise.
(lookup_tag_reverse): Likewise.
(lookup_namespace_name): Likewise.
(select_decl): Likewise.
(unqualified_namespace_lookup): Likewise.
(lookup_name_real): Likewise.
(lookup_name_current_level): Likewise.
(lookup_type_current_level): Likewise.
(maybe_inject_for_scope_var): Likewise.
(xref_tag): Likewise.
* Make-lang.in (cp/decl.o): Add dependency on timevar.h
Index: timevar.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/timevar.h,v
retrieving revision 1.9
diff -p -r1.9 timevar.h
*** timevar.h 16 Dec 2002 18:19:59 -0000 1.9
--- timevar.h 13 Feb 2003 04:55:28 -0000
*************** typedef enum
*** 76,81 ****
--- 76,84 ----
timevar_id_t;
#undef DEFTIMEVAR
+ /* Execute the sequence: timevar_pop (TV), return (E); */
+ #define POP_TIMEVAR_AND_RETURN(TV, E) return (timevar_pop (TV), (E))
+
extern void init_timevar PARAMS ((void));
extern void timevar_push PARAMS ((timevar_id_t));
extern void timevar_pop PARAMS ((timevar_id_t));
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.133
diff -p -r1.133 Make-lang.in
*** cp/Make-lang.in 31 Jan 2003 01:42:38 -0000 1.133
--- cp/Make-lang.in 13 Feb 2003 04:55:28 -0000
*************** cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H)
*** 221,227 ****
cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \
output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \
! debug.h gt-cp-decl.h gtype-cp.h
cp/decl2.o: cp/decl2.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
output.h except.h toplev.h $(RTL_H) c-common.h gt-cp-decl2.h
cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h output.h $(TM_P_H) \
--- 221,227 ----
cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \
output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \
! debug.h gt-cp-decl.h gtype-cp.h timevar.h
cp/decl2.o: cp/decl2.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
output.h except.h toplev.h $(RTL_H) c-common.h gt-cp-decl2.h
cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h output.h $(TM_P_H) \
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.994
diff -p -r1.994 decl.c
*** cp/decl.c 13 Feb 2003 03:50:18 -0000 1.994
--- cp/decl.c 13 Feb 2003 04:55:28 -0000
*************** Boston, MA 02111-1307, USA. */
*** 50,55 ****
--- 50,56 ----
#include "c-pragma.h"
#include "diagnostic.h"
#include "debug.h"
+ #include "timevar.h"
static tree grokparms (tree);
static const char *redeclaration_error_message (tree, tree);
*************** poplevel (int keep, int reverse, int fun
*** 1234,1241 ****
tree decl;
int leaving_for_scope;
if (cfun && !doing_semantic_analysis_p ())
! return NULL_TREE;
my_friendly_assert (current_binding_level->parm_flag != 2,
19990916);
--- 1235,1243 ----
tree decl;
int leaving_for_scope;
+ timevar_push (TV_NAME_LOOKUP);
if (cfun && !doing_semantic_analysis_p ())
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
my_friendly_assert (current_binding_level->parm_flag != 2,
19990916);
*************** poplevel (int keep, int reverse, int fun
*** 1526,1532 ****
block = poplevel (keep, reverse, functionbody);
}
! return block;
}
/* Delete the node BLOCK from the current binding level.
--- 1528,1534 ----
block = poplevel (keep, reverse, functionbody);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, block);
}
/* Delete the node BLOCK from the current binding level.
*************** poplevel_class (void)
*** 1614,1619 ****
--- 1616,1622 ----
register struct cp_binding_level *level = class_binding_level;
tree shadowed;
+ timevar_push (TV_NAME_LOOKUP);
my_friendly_assert (level != 0, 354);
/* If we're leaving a toplevel class, don't bother to do the setting
*************** poplevel_class (void)
*** 1678,1683 ****
--- 1681,1687 ----
#endif /* defined(DEBUG_BINDING_LEVELS) */
pop_binding_level ();
+ timevar_pop (TV_NAME_LOOKUP);
}
/* We are entering the scope of a class. Clear IDENTIFIER_CLASS_VALUE
*************** find_binding (tree name, tree scope)
*** 2032,2037 ****
--- 2036,2042 ----
{
tree iter, prev = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
scope = ORIGINAL_NAMESPACE (scope);
for (iter = IDENTIFIER_NAMESPACE_BINDINGS (name); iter;
*************** find_binding (tree name, tree scope)
*** 2048,2058 ****
TREE_CHAIN (iter) = IDENTIFIER_NAMESPACE_BINDINGS (name);
IDENTIFIER_NAMESPACE_BINDINGS (name) = iter;
}
! return iter;
}
prev = iter;
}
! return NULL_TREE;
}
/* Always returns a binding for name in scope. If the
--- 2053,2063 ----
TREE_CHAIN (iter) = IDENTIFIER_NAMESPACE_BINDINGS (name);
IDENTIFIER_NAMESPACE_BINDINGS (name) = iter;
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, iter);
}
prev = iter;
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* Always returns a binding for name in scope. If the
*************** push_namespace (tree name)
*** 2139,2144 ****
--- 2144,2152 ----
int need_new = 1;
int implicit_use = 0;
int global = 0;
+
+ timevar_push (TV_NAME_LOOKUP);
+
if (!global_namespace)
{
/* This must be ::. */
*************** push_namespace (tree name)
*** 2196,2201 ****
--- 2204,2211 ----
do_using_directive (d);
/* Enter the name space. */
current_namespace = d;
+
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Pop from the scope of the current namespace. */
*************** push_nested_namespace (tree ns)
*** 2230,2235 ****
--- 2240,2246 ----
void
pop_nested_namespace (tree ns)
{
+ timevar_push (TV_NAME_LOOKUP);
while (ns != global_namespace)
{
pop_namespace ();
*************** pop_nested_namespace (tree ns)
*** 2237,2242 ****
--- 2248,2254 ----
}
pop_from_top_level ();
+ timevar_pop (TV_NAME_LOOKUP);
}
*************** store_bindings (tree names, tree old_bin
*** 2253,2258 ****
--- 2265,2271 ----
tree t;
tree search_bindings = old_bindings;
+ timevar_push (TV_NAME_LOOKUP);
for (t = names; t; t = TREE_CHAIN (t))
{
tree binding, t1, id;
*************** store_bindings (tree names, tree old_bin
*** 2286,2292 ****
skip_it:
;
}
! return old_bindings;
}
void
--- 2299,2305 ----
skip_it:
;
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, old_bindings);
}
void
*************** maybe_push_to_top_level (int pseudo)
*** 2297,2302 ****
--- 2310,2316 ----
tree old_bindings;
int need_pop;
+ timevar_push (TV_NAME_LOOKUP);
s = (struct saved_scope *) ggc_alloc_cleared (sizeof (struct saved_scope));
b = scope_chain ? current_binding_level : 0;
*************** maybe_push_to_top_level (int pseudo)
*** 2350,2355 ****
--- 2364,2370 ----
VARRAY_TREE_INIT (current_lang_base, 10, "current_lang_base");
current_lang_name = lang_name_cplusplus;
current_namespace = global_namespace;
+ timevar_pop (TV_NAME_LOOKUP);
}
void
*************** pop_from_top_level (void)
*** 2364,2369 ****
--- 2379,2385 ----
struct saved_scope *s = scope_chain;
tree t;
+ timevar_push (TV_NAME_LOOKUP);
/* Clear out class-level bindings cache. */
if (previous_class_type)
invalidate_class_lookup_cache ();
*************** pop_from_top_level (void)
*** 2386,2391 ****
--- 2402,2408 ----
pop_function_context_from (NULL_TREE);
current_function_decl = s->function_decl;
last_function_parms = s->last_parms;
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Push a definition of struct, union or enum tag "name".
*************** set_identifier_type_value (tree id, tree
*** 2437,2454 ****
tree
identifier_type_value (tree id)
{
/* There is no type with that name, anywhere. */
if (REAL_IDENTIFIER_TYPE_VALUE (id) == NULL_TREE)
! return NULL_TREE;
/* This is not the type marker, but the real thing. */
if (REAL_IDENTIFIER_TYPE_VALUE (id) != global_type_node)
! return REAL_IDENTIFIER_TYPE_VALUE (id);
/* Have to search for it. It must be on the global level, now.
Ask lookup_name not to return non-types. */
id = lookup_name_real (id, 2, 1, 0, LOOKUP_COMPLAIN);
if (id)
! return TREE_TYPE (id);
! return NULL_TREE;
}
/* Pop off extraneous binding levels left over due to syntax errors.
--- 2454,2472 ----
tree
identifier_type_value (tree id)
{
+ timevar_push (TV_NAME_LOOKUP);
/* There is no type with that name, anywhere. */
if (REAL_IDENTIFIER_TYPE_VALUE (id) == NULL_TREE)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
/* This is not the type marker, but the real thing. */
if (REAL_IDENTIFIER_TYPE_VALUE (id) != global_type_node)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, REAL_IDENTIFIER_TYPE_VALUE (id));
/* Have to search for it. It must be on the global level, now.
Ask lookup_name not to return non-types. */
id = lookup_name_real (id, 2, 1, 0, LOOKUP_COMPLAIN);
if (id)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, TREE_TYPE (id));
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* Pop off extraneous binding levels left over due to syntax errors.
*************** push_local_name (tree decl)
*** 2571,2576 ****
--- 2589,2595 ----
size_t i, nelts;
tree t, name;
+ timevar_push (TV_NAME_LOOKUP);
if (!local_names)
VARRAY_TREE_INIT (local_names, 8, "local_names");
*************** push_local_name (tree decl)
*** 2591,2601 ****
DECL_DISCRIMINATOR (decl) = 1;
VARRAY_TREE (local_names, i) = decl;
! return;
}
}
VARRAY_PUSH_TREE (local_names, decl);
}
/* Push a tag name NAME for struct/class/union/enum type TYPE.
--- 2610,2621 ----
DECL_DISCRIMINATOR (decl) = 1;
VARRAY_TREE (local_names, i) = decl;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
}
}
VARRAY_PUSH_TREE (local_names, decl);
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Push a tag name NAME for struct/class/union/enum type TYPE.
*************** pushtag (tree name, tree type, int globa
*** 2608,2613 ****
--- 2628,2634 ----
{
register struct cp_binding_level *b;
+ timevar_push (TV_NAME_LOOKUP);
b = current_binding_level;
while (b->tag_transparent
|| (b->parm_flag == 2
*************** pushtag (tree name, tree type, int globa
*** 2717,2722 ****
--- 2738,2744 ----
tree d = build_decl (TYPE_DECL, NULL_TREE, type);
TYPE_STUB_DECL (type) = pushdecl_with_scope (d, b);
}
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Counter used to create anonymous type names. */
*************** pushdecl (tree x)
*** 3686,3691 ****
--- 3708,3714 ----
register tree name;
int need_new_binding;
+ timevar_push (TV_NAME_LOOKUP);
/* We shouldn't be calling pushdecl when we're generating RTL for a
function that we already did semantic analysis on previously. */
my_friendly_assert (!cfun || doing_semantic_analysis_p (),
*************** pushdecl (tree x)
*** 3809,3815 ****
/* Check for duplicate params. */
if (duplicate_decls (x, t))
! return t;
}
else if ((DECL_EXTERN_C_FUNCTION_P (x)
|| DECL_FUNCTION_TEMPLATE_P (x))
--- 3832,3838 ----
/* Check for duplicate params. */
if (duplicate_decls (x, t))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
else if ((DECL_EXTERN_C_FUNCTION_P (x)
|| DECL_FUNCTION_TEMPLATE_P (x))
*************** pushdecl (tree x)
*** 3822,3833 ****
TREE_TYPE (x));
/* Throw away the redeclaration. */
! return t;
}
else if (TREE_CODE (t) != TREE_CODE (x))
{
if (duplicate_decls (x, t))
! return t;
}
else if (duplicate_decls (x, t))
{
--- 3845,3856 ----
TREE_TYPE (x));
/* Throw away the redeclaration. */
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
else if (TREE_CODE (t) != TREE_CODE (x))
{
if (duplicate_decls (x, t))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
else if (duplicate_decls (x, t))
{
*************** pushdecl (tree x)
*** 3836,3842 ****
else if (TREE_CODE (t) == FUNCTION_DECL)
check_default_args (t);
! return t;
}
else if (DECL_MAIN_P (x))
{
--- 3859,3865 ----
else if (TREE_CODE (t) == FUNCTION_DECL)
check_default_args (t);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
else if (DECL_MAIN_P (x))
{
*************** pushdecl (tree x)
*** 3850,3856 ****
error ("as `%D'", x);
/* We don't try to push this declaration since that
causes a crash. */
! return x;
}
}
--- 3873,3879 ----
error ("as `%D'", x);
/* We don't try to push this declaration since that
causes a crash. */
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, x);
}
}
*************** pushdecl (tree x)
*** 3868,3874 ****
{
t = push_overloaded_decl (x, PUSH_LOCAL);
if (t != x)
! return t;
if (!namespace_bindings_p ())
/* We do not need to create a binding for this name;
push_overloaded_decl will have already done so if
--- 3891,3897 ----
{
t = push_overloaded_decl (x, PUSH_LOCAL);
if (t != x)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
if (!namespace_bindings_p ())
/* We do not need to create a binding for this name;
push_overloaded_decl will have already done so if
*************** pushdecl (tree x)
*** 3880,3886 ****
t = push_overloaded_decl (x, PUSH_GLOBAL);
if (t == x)
add_decl_to_level (x, NAMESPACE_LEVEL (CP_DECL_CONTEXT (t)));
! return t;
}
/* If declaring a type as a typedef, copy the type (unless we're
--- 3903,3909 ----
t = push_overloaded_decl (x, PUSH_GLOBAL);
if (t == x)
add_decl_to_level (x, NAMESPACE_LEVEL (CP_DECL_CONTEXT (t)));
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
/* If declaring a type as a typedef, copy the type (unless we're
*************** pushdecl (tree x)
*** 4119,4125 ****
? NAMESPACE_LEVEL (CP_DECL_CONTEXT (x))
: current_binding_level);
! return x;
}
/* Same as pushdecl, but define X in binding-level LEVEL. We rely on the
--- 4142,4148 ----
? NAMESPACE_LEVEL (CP_DECL_CONTEXT (x))
: current_binding_level);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, x);
}
/* Same as pushdecl, but define X in binding-level LEVEL. We rely on the
*************** pushdecl_with_scope (tree x, struct cp_b
*** 4131,4136 ****
--- 4154,4160 ----
register struct cp_binding_level *b;
tree function_decl = current_function_decl;
+ timevar_push (TV_NAME_LOOKUP);
current_function_decl = NULL_TREE;
if (level->parm_flag == 2)
{
*************** pushdecl_with_scope (tree x, struct cp_b
*** 4147,4153 ****
current_binding_level = b;
}
current_function_decl = function_decl;
! return x;
}
/* Like pushdecl, only it places X in the current namespace,
--- 4171,4177 ----
current_binding_level = b;
}
current_function_decl = function_decl;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, x);
}
/* Like pushdecl, only it places X in the current namespace,
*************** pushdecl_namespace_level (tree x)
*** 4159,4164 ****
--- 4183,4189 ----
register struct cp_binding_level *b = current_binding_level;
register tree t;
+ timevar_push (TV_NAME_LOOKUP);
t = pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace));
/* Now, the type_shadowed stack may screw us. Munge it so it does
*************** pushdecl_namespace_level (tree x)
*** 4192,4198 ****
*ptr = newval;
}
}
! return t;
}
/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL,
--- 4217,4223 ----
*ptr = newval;
}
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL,
*************** pushdecl_namespace_level (tree x)
*** 4201,4210 ****
tree
pushdecl_top_level (tree x)
{
push_to_top_level ();
x = pushdecl_namespace_level (x);
pop_from_top_level ();
! return x;
}
/* Make the declaration of X appear in CLASS scope. */
--- 4226,4236 ----
tree
pushdecl_top_level (tree x)
{
+ timevar_push (TV_NAME_LOOKUP);
push_to_top_level ();
x = pushdecl_namespace_level (x);
pop_from_top_level ();
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, x);
}
/* Make the declaration of X appear in CLASS scope. */
*************** pushdecl_class_level (tree x)
*** 4214,4219 ****
--- 4240,4246 ----
{
tree name;
+ timevar_push (TV_NAME_LOOKUP);
/* Get the name of X. */
if (TREE_CODE (x) == OVERLOAD)
name = DECL_NAME (get_first_fn (x));
*************** pushdecl_class_level (tree x)
*** 4236,4241 ****
--- 4263,4269 ----
for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = TREE_CHAIN (f))
pushdecl_class_level (f);
}
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Enter DECL into the symbol table, if that's appropriate. Returns
*************** void
*** 4274,4283 ****
push_class_level_binding (tree name, tree x)
{
tree binding;
/* The class_binding_level will be NULL if x is a template
parameter name in a member template. */
if (!class_binding_level)
! return;
/* Make sure that this new member does not have the same name
as a template parameter. */
--- 4302,4312 ----
push_class_level_binding (tree name, tree x)
{
tree binding;
+ timevar_push (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)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
/* Make sure that this new member does not have the same name
as a template parameter. */
*************** push_class_level_binding (tree name, tre
*** 4327,4333 ****
INHERITED_VALUE_BINDING_P (binding) = 0;
TREE_TYPE (shadow) = x;
IDENTIFIER_CLASS_VALUE (name) = x;
! return;
}
}
--- 4356,4362 ----
INHERITED_VALUE_BINDING_P (binding) = 0;
TREE_TYPE (shadow) = x;
IDENTIFIER_CLASS_VALUE (name) = x;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
}
}
*************** push_class_level_binding (tree name, tre
*** 4342,4347 ****
--- 4371,4377 ----
what to pop later. */
TREE_TYPE (class_binding_level->class_shadowed) = x;
}
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Insert another USING_DECL into the current binding level, returning
*************** push_using_decl (tree scope, tree name)
*** 4354,4371 ****
{
tree decl;
my_friendly_assert (TREE_CODE (scope) == NAMESPACE_DECL, 383);
my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 384);
for (decl = current_binding_level->usings; decl; decl = TREE_CHAIN (decl))
if (DECL_INITIAL (decl) == scope && DECL_NAME (decl) == name)
break;
if (decl)
! return namespace_bindings_p () ? decl : NULL_TREE;
decl = build_lang_decl (USING_DECL, name, void_type_node);
DECL_INITIAL (decl) = scope;
TREE_CHAIN (decl) = current_binding_level->usings;
current_binding_level->usings = decl;
! return decl;
}
/* Add namespace to using_directives. Return NULL_TREE if nothing was
--- 4384,4403 ----
{
tree decl;
+ timevar_push (TV_NAME_LOOKUP);
my_friendly_assert (TREE_CODE (scope) == NAMESPACE_DECL, 383);
my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 384);
for (decl = current_binding_level->usings; decl; decl = TREE_CHAIN (decl))
if (DECL_INITIAL (decl) == scope && DECL_NAME (decl) == name)
break;
if (decl)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP,
! namespace_bindings_p () ? decl : NULL_TREE);
decl = build_lang_decl (USING_DECL, name, void_type_node);
DECL_INITIAL (decl) = scope;
TREE_CHAIN (decl) = current_binding_level->usings;
current_binding_level->usings = decl;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
/* Add namespace to using_directives. Return NULL_TREE if nothing was
*************** push_using_directive (tree used)
*** 4378,4386 ****
tree ud = current_binding_level->using_directives;
tree iter, ancestor;
/* Check if we already have this. */
if (purpose_member (used, ud) != NULL_TREE)
! return NULL_TREE;
/* Recursively add all namespaces used. */
for (iter = DECL_NAMESPACE_USING (used); iter; iter = TREE_CHAIN (iter))
--- 4410,4419 ----
tree ud = current_binding_level->using_directives;
tree iter, ancestor;
+ timevar_push (TV_NAME_LOOKUP);
/* Check if we already have this. */
if (purpose_member (used, ud) != NULL_TREE)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
/* Recursively add all namespaces used. */
for (iter = DECL_NAMESPACE_USING (used); iter; iter = TREE_CHAIN (iter))
*************** push_using_directive (tree used)
*** 4390,4396 ****
ud = current_binding_level->using_directives;
ud = tree_cons (used, ancestor, ud);
current_binding_level->using_directives = ud;
! return ud;
}
/* DECL is a FUNCTION_DECL for a non-member function, which may have
--- 4423,4429 ----
ud = current_binding_level->using_directives;
ud = tree_cons (used, ancestor, ud);
current_binding_level->using_directives = ud;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ud);
}
/* DECL is a FUNCTION_DECL for a non-member function, which may have
*************** push_overloaded_decl (tree decl, int fla
*** 4420,4425 ****
--- 4453,4459 ----
tree new_binding;
int doing_global = (namespace_bindings_p () || !(flags & PUSH_LOCAL));
+ timevar_push (TV_NAME_LOOKUP);
if (doing_global)
old = namespace_binding (name, DECL_CONTEXT (decl));
else
*************** push_overloaded_decl (tree decl, int fla
*** 4452,4458 ****
decl, fn);
if (duplicate_decls (decl, fn))
! return fn;
}
}
else if (old == error_mark_node)
--- 4486,4492 ----
decl, fn);
if (duplicate_decls (decl, fn))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, fn);
}
}
else if (old == error_mark_node)
*************** push_overloaded_decl (tree decl, int fla
*** 4462,4468 ****
{
cp_error_at ("previous non-function declaration `%#D'", old);
error ("conflicts with function declaration `%#D'", decl);
! return decl;
}
}
--- 4496,4502 ----
{
cp_error_at ("previous non-function declaration `%#D'", old);
error ("conflicts with function declaration `%#D'", decl);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
}
*************** push_overloaded_decl (tree decl, int fla
*** 4511,4517 ****
/* And update the CPLUS_BINDING node. */
BINDING_VALUE (IDENTIFIER_BINDING (name))
= new_binding;
! return decl;
}
/* We should always find a previous binding in this case. */
--- 4545,4551 ----
/* And update the CPLUS_BINDING node. */
BINDING_VALUE (IDENTIFIER_BINDING (name))
= new_binding;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
/* We should always find a previous binding in this case. */
*************** push_overloaded_decl (tree decl, int fla
*** 4522,4528 ****
push_local_binding (name, new_binding, flags);
}
! return decl;
}
/* Generate an implicit declaration for identifier FUNCTIONID
--- 4556,4562 ----
push_local_binding (name, new_binding, flags);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
/* Generate an implicit declaration for identifier FUNCTIONID
*************** lookup_label (tree id)
*** 4700,4717 ****
tree decl;
struct named_label_list *ent;
/* You can't use labels at global scope. */
if (current_function_decl == NULL_TREE)
{
error ("label `%s' referenced outside of any function",
IDENTIFIER_POINTER (id));
! return NULL_TREE;
}
/* See if we've already got this label. */
decl = IDENTIFIER_LABEL_VALUE (id);
if (decl != NULL_TREE && DECL_CONTEXT (decl) == current_function_decl)
! return decl;
/* Record this label on the list of labels used in this function.
We do this before calling make_label_decl so that we get the
--- 4734,4752 ----
tree decl;
struct named_label_list *ent;
+ timevar_push (TV_NAME_LOOKUP);
/* You can't use labels at global scope. */
if (current_function_decl == NULL_TREE)
{
error ("label `%s' referenced outside of any function",
IDENTIFIER_POINTER (id));
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* See if we've already got this label. */
decl = IDENTIFIER_LABEL_VALUE (id);
if (decl != NULL_TREE && DECL_CONTEXT (decl) == current_function_decl)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
/* Record this label on the list of labels used in this function.
We do this before calling make_label_decl so that we get the
*************** lookup_label (tree id)
*** 4728,4734 ****
/* Now fill in the information we didn't have before. */
ent->label_decl = decl;
! return decl;
}
/* Declare a local label named ID. */
--- 4763,4769 ----
/* Now fill in the information we didn't have before. */
ent->label_decl = decl;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
/* Declare a local label named ID. */
*************** define_label (const char* filename, int
*** 4952,4957 ****
--- 4987,4993 ----
struct named_label_list *ent;
register struct cp_binding_level *p;
+ timevar_push (TV_NAME_LOOKUP);
for (ent = named_labels; ent; ent = ent->next)
if (ent->label_decl == decl)
break;
*************** define_label (const char* filename, int
*** 4967,4973 ****
if (DECL_INITIAL (decl) != NULL_TREE)
{
error ("duplicate label `%D'", decl);
! return 0;
}
else
{
--- 5003,5009 ----
if (DECL_INITIAL (decl) != NULL_TREE)
{
error ("duplicate label `%D'", decl);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, 0);
}
else
{
*************** define_label (const char* filename, int
*** 4982,4989 ****
ent->binding_level = current_binding_level;
}
check_previous_gotos (decl);
! return decl;
}
}
struct cp_switch
--- 5018,5026 ----
ent->binding_level = current_binding_level;
}
check_previous_gotos (decl);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
+ timevar_pop (TV_NAME_LOOKUP);
}
struct cp_switch
*************** lookup_tag (enum tree_code form,
*** 5181,5186 ****
--- 5218,5224 ----
if THISLEVEL_ONLY. */
int allow_template_parms_p = 1;
+ timevar_push (TV_NAME_LOOKUP);
for (level = binding_level; level; level = level->level_chain)
{
register tree tail;
*************** lookup_tag (enum tree_code form,
*** 5190,5196 ****
/* There's no need for error checking here, because
anon names are unique throughout the compilation. */
if (TYPE_IDENTIFIER (TREE_VALUE (tail)) == name)
! return TREE_VALUE (tail);
}
else if (level->namespace_p)
/* Do namespace lookup. */
--- 5228,5234 ----
/* There's no need for error checking here, because
anon names are unique throughout the compilation. */
if (TYPE_IDENTIFIER (TREE_VALUE (tail)) == name)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, TREE_VALUE (tail));
}
else if (level->namespace_p)
/* Do namespace lookup. */
*************** lookup_tag (enum tree_code form,
*** 5216,5233 ****
if the typedef doesn't refer to a taggable type. */
old = follow_tag_typedef (old);
if (!old)
! return NULL_TREE;
if (TREE_CODE (old) != form
&& (form == ENUMERAL_TYPE
|| TREE_CODE (old) == ENUMERAL_TYPE))
{
error ("`%#D' redeclared as %C", old, form);
! return NULL_TREE;
}
! return old;
}
if (thislevel_only || tail == global_namespace)
! return NULL_TREE;
}
else
for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
--- 5254,5271 ----
if the typedef doesn't refer to a taggable type. */
old = follow_tag_typedef (old);
if (!old)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
if (TREE_CODE (old) != form
&& (form == ENUMERAL_TYPE
|| TREE_CODE (old) == ENUMERAL_TYPE))
{
error ("`%#D' redeclared as %C", old, form);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, old);
}
if (thislevel_only || tail == global_namespace)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
else
for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
*************** lookup_tag (enum tree_code form,
*** 5241,5249 ****
{
/* Definition isn't the kind we were looking for. */
error ("`%#D' redeclared as %C", TREE_VALUE (tail), form);
! return NULL_TREE;
}
! return TREE_VALUE (tail);
}
}
if (thislevel_only && ! level->tag_transparent)
--- 5279,5287 ----
{
/* Definition isn't the kind we were looking for. */
error ("`%#D' redeclared as %C", TREE_VALUE (tail), form);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, TREE_VALUE (tail));
}
}
if (thislevel_only && ! level->tag_transparent)
*************** lookup_tag (enum tree_code form,
*** 5265,5274 ****
continue;
}
else
! return NULL_TREE;
}
}
! return NULL_TREE;
}
/* Given a type, find the tag that was defined for it and return the tag name.
--- 5303,5312 ----
continue;
}
else
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* Given a type, find the tag that was defined for it and return the tag name.
*************** lookup_tag_reverse (tree type, tree name
*** 5283,5288 ****
--- 5321,5327 ----
{
register struct cp_binding_level *level;
+ timevar_push (TV_NAME_LOOKUP);
for (level = current_binding_level; level; level = level->level_chain)
{
register tree tail;
*************** lookup_tag_reverse (tree type, tree name
*** 5292,5302 ****
{
if (name)
TREE_PURPOSE (tail) = name;
! return TREE_PURPOSE (tail);
}
}
}
! return NULL_TREE;
}
/* Look up NAME in the NAMESPACE. */
--- 5331,5341 ----
{
if (name)
TREE_PURPOSE (tail) = name;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, TREE_PURPOSE (tail));
}
}
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* Look up NAME in the NAMESPACE. */
*************** lookup_namespace_name (tree namespace, t
*** 5307,5323 ****
tree val;
tree template_id = NULL_TREE;
my_friendly_assert (TREE_CODE (namespace) == NAMESPACE_DECL, 370);
if (TREE_CODE (name) == NAMESPACE_DECL)
/* This happens for A::B<int> when B is a namespace. */
! return name;
else if (TREE_CODE (name) == TEMPLATE_DECL)
{
/* This happens for A::B where B is a template, and there are no
template arguments. */
error ("invalid use of `%D'", name);
! return error_mark_node;
}
namespace = ORIGINAL_NAMESPACE (namespace);
--- 5346,5363 ----
tree val;
tree template_id = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
my_friendly_assert (TREE_CODE (namespace) == NAMESPACE_DECL, 370);
if (TREE_CODE (name) == NAMESPACE_DECL)
/* This happens for A::B<int> when B is a namespace. */
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, name);
else if (TREE_CODE (name) == TEMPLATE_DECL)
{
/* This happens for A::B where B is a template, and there are no
template arguments. */
error ("invalid use of `%D'", name);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
namespace = ORIGINAL_NAMESPACE (namespace);
*************** lookup_namespace_name (tree namespace, t
*** 5336,5342 ****
val = make_node (CPLUS_BINDING);
if (!qualified_lookup_using_namespace (name, namespace, val, 0))
! return error_mark_node;
if (BINDING_VALUE (val))
{
--- 5376,5382 ----
val = make_node (CPLUS_BINDING);
if (!qualified_lookup_using_namespace (name, namespace, val, 0))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
if (BINDING_VALUE (val))
{
*************** lookup_namespace_name (tree namespace, t
*** 5359,5365 ****
{
error ("`%D::%D' is not a template",
namespace, name);
! return error_mark_node;
}
}
--- 5399,5405 ----
{
error ("`%D::%D' is not a template",
namespace, name);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
}
*************** lookup_namespace_name (tree namespace, t
*** 5371,5381 ****
if (!val || !DECL_P(val)
|| !DECL_LANG_SPECIFIC(val)
|| !DECL_ANTICIPATED (val))
! return val;
}
error ("`%D' undeclared in namespace `%D'", name, namespace);
! return error_mark_node;
}
/* Hash a TYPENAME_TYPE. K is really of type `tree'. */
--- 5411,5421 ----
if (!val || !DECL_P(val)
|| !DECL_LANG_SPECIFIC(val)
|| !DECL_ANTICIPATED (val))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
}
error ("`%D' undeclared in namespace `%D'", name, namespace);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
/* Hash a TYPENAME_TYPE. K is really of type `tree'. */
*************** select_decl (tree binding, int flags)
*** 5660,5671 ****
tree val;
val = BINDING_VALUE (binding);
if (LOOKUP_NAMESPACES_ONLY (flags))
{
/* We are not interested in types. */
if (val && TREE_CODE (val) == NAMESPACE_DECL)
! return val;
! return NULL_TREE;
}
/* If we could have a type and
--- 5700,5712 ----
tree val;
val = BINDING_VALUE (binding);
+ timevar_push (TV_NAME_LOOKUP);
if (LOOKUP_NAMESPACES_ONLY (flags))
{
/* We are not interested in types. */
if (val && TREE_CODE (val) == NAMESPACE_DECL)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
/* If we could have a type and
*************** select_decl (tree binding, int flags)
*** 5680,5686 ****
|| !DECL_CLASS_TEMPLATE_P (val)))
val = NULL_TREE;
! return val;
}
/* Unscoped lookup of a global: iterate over current namespaces,
--- 5721,5727 ----
|| !DECL_CLASS_TEMPLATE_P (val)))
val = NULL_TREE;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
}
/* Unscoped lookup of a global: iterate over current namespaces,
*************** unqualified_namespace_lookup (tree name,
*** 5697,5702 ****
--- 5738,5744 ----
struct cp_binding_level *level;
tree val = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
if (spacesp)
*spacesp = NULL_TREE;
*************** unqualified_namespace_lookup (tree name,
*** 5729,5735 ****
if (!lookup_using_namespace (name, b, level->using_directives,
scope, flags, spacesp))
/* Give up because of error. */
! return error_mark_node;
/* Add all _DECLs seen through global using-directives. */
/* XXX local and global using lists should work equally. */
--- 5771,5777 ----
if (!lookup_using_namespace (name, b, level->using_directives,
scope, flags, spacesp))
/* Give up because of error. */
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
/* Add all _DECLs seen through global using-directives. */
/* XXX local and global using lists should work equally. */
*************** unqualified_namespace_lookup (tree name,
*** 5739,5745 ****
if (!lookup_using_namespace (name, b, DECL_NAMESPACE_USING (siter),
scope, flags, spacesp))
/* Give up because of error. */
! return error_mark_node;
if (siter == scope) break;
siter = CP_DECL_CONTEXT (siter);
}
--- 5781,5787 ----
if (!lookup_using_namespace (name, b, DECL_NAMESPACE_USING (siter),
scope, flags, spacesp))
/* Give up because of error. */
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
if (siter == scope) break;
siter = CP_DECL_CONTEXT (siter);
}
*************** unqualified_namespace_lookup (tree name,
*** 5748,5754 ****
if (scope == global_namespace)
break;
}
! return val;
}
/* Combine prefer_type and namespaces_only into flags. */
--- 5790,5796 ----
if (scope == global_namespace)
break;
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
}
/* Combine prefer_type and namespaces_only into flags. */
*************** lookup_name_real (tree name,
*** 5890,5895 ****
--- 5932,5938 ----
tree t;
tree val = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
/* Conversion operators are handled specially because ordinary
unqualified name lookup will not find template conversion
operators. */
*************** lookup_name_real (tree name,
*** 5913,5922 ****
class_type = level->this_class;
operators = lookup_fnfields (class_type, name, /*protect=*/0);
if (operators)
! return operators;
}
! return NULL_TREE;
}
flags |= lookup_flags (prefer_type, namespaces_only);
--- 5956,5965 ----
class_type = level->this_class;
operators = lookup_fnfields (class_type, name, /*protect=*/0);
if (operators)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, operators);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
flags |= lookup_flags (prefer_type, namespaces_only);
*************** lookup_name_real (tree name,
*** 5965,5971 ****
val = OVL_FUNCTION (val);
}
! return val;
}
tree
--- 6008,6014 ----
val = OVL_FUNCTION (val);
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
}
tree
*************** lookup_name_current_level (tree name)
*** 5995,6000 ****
--- 6038,6044 ----
struct cp_binding_level *b;
tree t = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
b = current_binding_level;
while (b->parm_flag == 2)
b = b->level_chain;
*************** lookup_name_current_level (tree name)
*** 6013,6019 ****
while (1)
{
if (BINDING_LEVEL (IDENTIFIER_BINDING (name)) == b)
! return IDENTIFIER_VALUE (name);
if (b->keep == 2)
b = b->level_chain;
--- 6057,6063 ----
while (1)
{
if (BINDING_LEVEL (IDENTIFIER_BINDING (name)) == b)
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, IDENTIFIER_VALUE (name));
if (b->keep == 2)
b = b->level_chain;
*************** lookup_name_current_level (tree name)
*** 6022,6028 ****
}
}
! return t;
}
/* Like lookup_name_current_level, but for types. */
--- 6066,6072 ----
}
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
/* Like lookup_name_current_level, but for types. */
*************** lookup_type_current_level (tree name)
*** 6032,6037 ****
--- 6076,6082 ----
{
register tree t = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
my_friendly_assert (! current_binding_level->namespace_p, 980716);
if (REAL_IDENTIFIER_TYPE_VALUE (name) != NULL_TREE
*************** lookup_type_current_level (tree name)
*** 6041,6047 ****
while (1)
{
if (purpose_member (name, b->type_shadowed))
! return REAL_IDENTIFIER_TYPE_VALUE (name);
if (b->keep == 2)
b = b->level_chain;
else
--- 6086,6093 ----
while (1)
{
if (purpose_member (name, b->type_shadowed))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP,
! REAL_IDENTIFIER_TYPE_VALUE (name));
if (b->keep == 2)
b = b->level_chain;
else
*************** lookup_type_current_level (tree name)
*** 6049,6055 ****
}
}
! return t;
}
--- 6095,6101 ----
}
}
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
*************** make_rtl_for_nonlocal_decl (tree decl, t
*** 7892,7905 ****
void
maybe_inject_for_scope_var (tree decl)
{
if (!DECL_NAME (decl))
! return;
/* Declarations of __FUNCTION__ and its ilk appear magically when
the variable is first used. If that happens to be inside a
for-loop, we don't want to do anything special. */
if (DECL_PRETTY_FUNCTION_P (decl))
! return;
if (current_binding_level->is_for_scope)
{
--- 7938,7952 ----
void
maybe_inject_for_scope_var (tree decl)
{
+ timevar_push (TV_NAME_LOOKUP);
if (!DECL_NAME (decl))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
/* Declarations of __FUNCTION__ and its ilk appear magically when
the variable is first used. If that happens to be inside a
for-loop, we don't want to do anything special. */
if (DECL_PRETTY_FUNCTION_P (decl))
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
if (current_binding_level->is_for_scope)
{
*************** maybe_inject_for_scope_var (tree decl)
*** 7928,7933 ****
--- 7975,7981 ----
current_binding_level->is_for_scope = 0;
}
}
+ timevar_pop (TV_NAME_LOOKUP);
}
/* Generate code to initialize DECL (a local variable). */
*************** xref_tag (enum tag_types tag_code, tree
*** 12563,12568 ****
--- 12611,12617 ----
struct cp_binding_level *b = current_binding_level;
tree context = NULL_TREE;
+ timevar_push (TV_NAME_LOOKUP);
switch (tag_code)
{
case record_type:
*************** xref_tag (enum tag_types tag_code, tree
*** 12765,12771 ****
TYPE_ATTRIBUTES (ref) = attributes;
! return ref;
}
tree
--- 12814,12820 ----
TYPE_ATTRIBUTES (ref) = attributes;
! POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ref);
}
tree