From 92643fea9381b2d137f19d19e28e24a61dc44b0c Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 19 Mar 2001 23:50:04 +0000 Subject: 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 --- gcc/tree.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index 3143db4..573d7a2 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -182,10 +182,42 @@ void (*lang_unsave_expr_now) PARAMS ((tree)); /* If non-null, these are language-specific helper functions for unsafe_for_reeval. Return negative to not handle some tree. */ int (*lang_unsafe_for_reeval) PARAMS ((tree)); + +/* Set the DECL_ASSEMBLER_NAME for a node. If it is the sort of thing + that the assembler should talk about, set DECL_ASSEMBLER_NAME to an + appropriate IDENTIFIER_NODE. Otherwise, set it to the + ERROR_MARK_NODE to ensure that the assembler does not talk about + it. */ +void (*lang_set_decl_assembler_name) PARAMS ((tree)); tree global_trees[TI_MAX]; tree integer_types[itk_none]; +/* Set the DECL_ASSEMBLER_NAME for DECL. */ +void +set_decl_assembler_name (decl) + tree decl; +{ + /* The language-independent code should never use the + DECL_ASSEMBLER_NAME for lots of DECLs. Only FUNCTION_DECLs and + VAR_DECLs for variables with static storage duration need a real + DECL_ASSEMBLER_NAME. */ + if (TREE_CODE (decl) == FUNCTION_DECL + || (TREE_CODE (decl) == VAR_DECL + && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))) + /* By default, assume the name to use in assembly code is the + same as that used in the source language. (That's correct + for C, and GCC used to set DECL_ASSEMBLER_NAME to the same + value as DECL_NAME in build_decl, so this choice provides + backwards compatibility with existing front-ends. */ + SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl)); + else + /* Nobody should ever be asking for the DECL_ASSEMBLER_NAME of + these DECLs -- unless they're in language-dependent code, in + which case lang_set_decl_assembler_name should handle things. */ + abort (); +} + /* Init the principal obstacks. */ void @@ -199,6 +231,9 @@ init_obstacks () ggc_add_root (&type_hash_table, 1, sizeof type_hash_table, mark_type_hash); ggc_add_tree_root (global_trees, TI_MAX); ggc_add_tree_root (integer_types, itk_none); + + /* Set lang_set_decl_set_assembler_name to a default value. */ + lang_set_decl_assembler_name = set_decl_assembler_name; } void @@ -2557,7 +2592,6 @@ build_decl (code, name, type) as the type can suppress useless errors in the use of this variable. */ DECL_NAME (t) = name; - DECL_ASSEMBLER_NAME (t) = name; TREE_TYPE (t) = type; if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL) -- cgit v1.1