diff options
author | Mark Mitchell <mark@codesourcery.com> | 2001-03-19 23:50:04 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2001-03-19 23:50:04 +0000 |
commit | 92643fea9381b2d137f19d19e28e24a61dc44b0c (patch) | |
tree | 0e001bd33ab3dcdd688aa773f49f4ddf63c89df6 /gcc/cp/decl.c | |
parent | b90f4049d36e101e2090dd2c1a0595bdb3790ec2 (diff) | |
download | gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.zip gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.tar.gz gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.tar.bz2 |
Compute DECL_ASSEMBLER_NAME lazily.
* tree.h (DECL_ASSEMBLER_NAME): Compute it lazily.
(DECL_ASSEMBLER_NAME_SET_P): New macro.
(SET_DECL_ASSEMBLER_NAME): Likewise.
(COPY_DECL_ASSEMBLER_NAME): Likewise.
(set_decl_assembler_name): Declare.
(lang_set_decl_assembler_name): Likewise.
* tree.c (lang_set_decl_assembler_name): New variab.e
(set_decl_assembler_name): New function.
(init_obstacks): Set lang_set_decl_assembler_name.
(build_decl): Don't set DECL_ASSEMBLER_NAME.
* c-decl.c (duplicate_decls): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(builtin_function): Likewise.
(finish_decl): Likewise.
* dbxout.c (dbxout_type_methods): Likewise.
* ggc-common.c (ggc_mark_trees): Likewise.
* profile.c (output_func_start_profiler): Likewise.
* varasm.c (make_decl_rtl): Likewise.
* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(add_method): Remove optimization involving comparison of
DECL_ASSEMBLER_NAME.
(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(check_methods): Likewise.
(build_clone): Likewise.
(built_vtt): Likewise.
* cp-tree.h (DECL_NEEDED_P): Likewise.
* decl.c (pushtag): Likewise.
(duplicate_decls): Likewise.
(pushdecl): Likewise.
(builtin_function): Likewise.
(build_library_fn_1): Set DECL_LANGUAGE for library functions.
(build_cp_library_fn): Likewise.
(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(make_rtl_for_nonlocal_decl): Likewise.
(cp_finish_decl): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(start_function): Likewise.
(cp_missing_return_ok_p): Likewise.
* decl2.c (grokclassfn): Likewise.
(check_classfn): Likewise.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
* error.c (GLOBAL_IORD_P): Remove.
(dump_global_iord): Improve output.
(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
* except.c (nothrow_libfn_p): Summarily reject any function not in
namespace-scope.
* init.c (build_java_class_ref): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
* mangle.c (mangle_decl_string): Handle extern "C" functions.
(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
* method.c (set_mangled_name_for_decl): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
IDENTIFIER_GLOBAL_VALUE for the thunk.
* pt.c (set_mangled_name_for_template_decl): Remove.
(check_explicit_specialization): Don't use it.
(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
(tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Likewise.
* search.c (looup_field_1): Likewise.
* semantics.c (finish_named_return_value): Likewise.
* tree.c (init_tree): Set lang_set_decl_assembler_name.
* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.
* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
(layout_class): Likewise.
(layout_class_method): Likewise.
(emit_register_classes): Likewise.
* decl.c (builtin_function): Likewise.
(give_name_to_locals): Likewise.
From-SVN: r40642
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 100 |
1 files changed, 32 insertions, 68 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8a5857a..f540cc5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2827,7 +2827,6 @@ pushtag (name, type, globalize) DECL_IGNORED_P (d) = 1; TYPE_CONTEXT (type) = DECL_CONTEXT (d); - DECL_ASSEMBLER_NAME (d) = DECL_NAME (d); /* If this is a local class, keep track of it. We need this information for name-mangling, and so that it is possible to find @@ -2838,9 +2837,6 @@ pushtag (name, type, globalize) && TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL && !processing_template_decl) VARRAY_PUSH_TREE (local_classes, type); - - if (!uses_template_parms (type)) - DECL_ASSEMBLER_NAME (d) = mangle_type (type); } if (b->parm_flag == 2) { @@ -3161,7 +3157,7 @@ duplicate_decls (newdecl, olddecl) will be banished. */ DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl); SET_DECL_RTL (olddecl, DECL_RTL (newdecl)); - DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl); + COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl), newdecl); } @@ -3633,7 +3629,7 @@ duplicate_decls (newdecl, olddecl) if (! types_match) { DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl); - DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl); + COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl); SET_DECL_RTL (olddecl, DECL_RTL (newdecl)); } if (! types_match || new_defines_function) @@ -3683,7 +3679,7 @@ duplicate_decls (newdecl, olddecl) TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl); TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl); DECL_COMMON (newdecl) = DECL_COMMON (olddecl); - DECL_ASSEMBLER_NAME (newdecl) = DECL_ASSEMBLER_NAME (olddecl); + COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); if (TREE_CODE (newdecl) == FUNCTION_DECL) { @@ -3846,8 +3842,7 @@ pushdecl (x) if (TREE_CODE (x) == FUNCTION_DECL) for (match = t; match; match = OVL_NEXT (match)) { - if (DECL_ASSEMBLER_NAME (OVL_CURRENT (t)) - == DECL_ASSEMBLER_NAME (x)) + if (decls_match (OVL_CURRENT (match), x)) break; } else @@ -4028,32 +4023,15 @@ pushdecl (x) if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && TREE_PUBLIC (x)) TREE_PUBLIC (name) = 1; - /* Bind the mangled name for the entity. In the future, we - should not need to do this; mangled names are an - implementation detail of which the front-end should not - need to be aware. */ - if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x) - && t != NULL_TREE) - /* For an ordinary function, we create a binding from - the mangled name (i.e., NAME) to the DECL. But, for - an `extern "C"' function, the mangled name and the - ordinary name are the same so we need not do this. */ - && !DECL_EXTERN_C_FUNCTION_P (x)) - { - tree mangled_name; - - if (TREE_CODE (x) == TYPE_DECL || TREE_CODE (x) == VAR_DECL - || TREE_CODE (x) == NAMESPACE_DECL) - mangled_name = name; - else - mangled_name = DECL_ASSEMBLER_NAME (x); - - if (TREE_CODE (x) == FUNCTION_DECL) - my_friendly_assert - ((IDENTIFIER_GLOBAL_VALUE (mangled_name) == NULL_TREE) - || (IDENTIFIER_GLOBAL_VALUE (mangled_name) == x), 378); - SET_IDENTIFIER_NAMESPACE_VALUE (mangled_name, x); - } + /* Bind the name for the entity. */ + if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x) + && t != NULL_TREE) + && (TREE_CODE (x) == TYPE_DECL + || TREE_CODE (x) == VAR_DECL + || TREE_CODE (x) == NAMESPACE_DECL + || TREE_CODE (x) == CONST_DECL + || TREE_CODE (x) == TEMPLATE_DECL)) + SET_IDENTIFIER_NAMESPACE_VALUE (name, x); /* Don't forget if the function was used via an implicit decl. */ if (IDENTIFIER_IMPLICIT_DECL (name) @@ -6670,7 +6648,8 @@ builtin_function (name, type, code, class, libname) we cannot change DECL_ASSEMBLER_NAME until we have installed this function in the namespace. */ if (libname) - DECL_ASSEMBLER_NAME (decl) = get_identifier (libname); + SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname)); + make_decl_rtl (decl, NULL); /* Warn if a function in the namespace for users is used without an occasion to consider it declared. */ @@ -6695,6 +6674,7 @@ build_library_fn_1 (name, operator_code, type) DECL_ARTIFICIAL (fn) = 1; TREE_NOTHROW (fn) = 1; SET_OVERLOADED_OPERATOR_CODE (fn, operator_code); + DECL_LANGUAGE (fn) = lang_c; return fn; } @@ -6721,6 +6701,7 @@ build_cp_library_fn (name, operator_code, type) tree fn = build_library_fn_1 (name, operator_code, type); TREE_NOTHROW (fn) = TYPE_NOTHROW_P (type); DECL_CONTEXT (fn) = FROB_CONTEXT (current_namespace); + DECL_LANGUAGE (fn) = lang_cplusplus; set_mangled_name_for_decl (fn); return fn; } @@ -7534,9 +7515,7 @@ maybe_commonize_var (decl) /* else we lose. We can only do this if we can use common, which we can't if it has been initialized. */ - if (TREE_PUBLIC (decl)) - DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl); - else + if (!TREE_PUBLIC (decl)) { cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); cp_warning_at (" you can work around this by removing the initializer", decl); @@ -7721,7 +7700,7 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec) /* Set the DECL_ASSEMBLER_NAME for the variable. */ if (asmspec) - DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec); + SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec)); /* We don't create any RTL for local variables. */ if (DECL_FUNCTION_SCOPE_P (decl) && !TREE_STATIC (decl)) @@ -7751,12 +7730,15 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec) defer_p = 1; } - /* If we're deferring the variable, just make RTL. Do not actually - emit the variable. */ - if (defer_p) + /* If we're deferring the variable, we only need to make RTL if + there's an ASMSPEC. Otherwise, we'll lazily create it later when + we need it. (There's no way to lazily create RTL for things that + have assembly specs because the information about the specifier + isn't stored in the tree, yet) */ + if (defer_p && asmspec) make_decl_rtl (decl, asmspec); /* If we're not deferring, go ahead and assemble the variable. */ - else + else if (!defer_p) rest_of_decl_compilation (decl, asmspec, toplev, at_eof); } @@ -8034,7 +8016,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) /* This must override the asm specifier which was placed by grokclassfn. Lay this out fresh. */ SET_DECL_RTL (TREE_TYPE (decl), NULL_RTX); - DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec); + SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec)); make_decl_rtl (decl, asmspec); } @@ -8858,12 +8840,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, if (has_default_arg) add_defarg_fn (decl); - /* Plain overloading: will not be grok'd by grokclassfn. */ - if (! ctype && ! processing_template_decl - && (! DECL_EXTERN_C_P (decl) || DECL_OVERLOADED_OPERATOR_P (decl)) - && ! DECL_USE_TEMPLATE (decl)) - set_mangled_name_for_decl (decl); - if (funcdef_flag) /* Make the init_value nonzero so pushdecl knows this is not tentative. error_mark_node is replaced later with the BLOCK. */ @@ -8968,10 +8944,6 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) type = TREE_TYPE (type); decl = build_lang_decl (VAR_DECL, declarator, type); DECL_CONTEXT (decl) = basetype; - /* DECL_ASSEMBLER_NAME is needed only for full-instantiated - templates. */ - if (!uses_template_parms (decl)) - DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl); } else { @@ -8996,7 +8968,10 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) context = DECL_CONTEXT (decl); if (declarator && context && current_lang_name != lang_name_c) - DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl); + /* We can't mangle lazily here because we don't have any + way to recover whether or not a variable was `extern + "C"' later. */ + mangle_decl (decl); } if (in_namespace) @@ -11005,8 +10980,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) DECL_NAME (CLASSTYPE_TI_TEMPLATE (type)) = TYPE_IDENTIFIER (type); - DECL_ASSEMBLER_NAME (decl) = mangle_type (type); - /* FIXME remangle member functions; member functions of a type with external linkage have external linkage. */ } @@ -13537,19 +13510,10 @@ start_function (declspecs, declarator, attrs, flags) if (attrs) cplus_decl_attributes (decl1, NULL_TREE, attrs); - /* We need to do this even if we aren't expanding yet so that - assemble_external works. */ - make_decl_rtl (decl1, NULL); - /* Promote the value to int before returning it. */ if (C_PROMOTING_INTEGER_TYPE_P (restype)) restype = type_promotes_to (restype); - /* If this fcn was already referenced via a block-scope `extern' decl - (or an implicit decl), propagate certain information about the usage. */ - if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl1))) - TREE_ADDRESSABLE (decl1) = 1; - if (DECL_RESULT (decl1) == NULL_TREE) { DECL_RESULT (decl1) @@ -14488,5 +14452,5 @@ cp_missing_noreturn_ok_p (decl) tree decl; { /* A missing noreturn is ok for the `main' function. */ - return MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl)); + return DECL_MAIN_P (decl); } |