From 288131c6f02a62d0accc753401931affa3fc33ce Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 9 Jun 2008 15:00:37 +0000 Subject: 2008-06-09 Rafael Espindola based on http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00349.html * langhooks-def.h (LANG_HOOKS_RESET_LANG_SPECIFICS): New. (LANG_HOOKS_INITIALIZER): add LANG_HOOKS_RESET_LANG_SPECIFICS. * langhooks.h (reset_lang_specifics): New. * lto-section-out.c (produce_asm_for_decls): Call free_lang_specifics. * tree.c (uid2type_map): New. (insert_type_to_uid_type_map): New. (uid_type_map_eq): New. (uid_type_map_hash): New. (init_ttree): Initialize uid2type_map. (make_node_stat): Call insert_type_to_uid_type_map. (copy_node_stat): Call insert_type_to_uid_type_map. (reset_type_lang_specific): New. (free_lang_specifics): New. * tree.h (free_lang_specifics) New. 2008-06-09 Rafael Espindola based on http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00349.html * cp-objcp-common.h (LANG_HOOKS_RESET_LANG_SPECIFICS): New. * cp-tree.h (cp_reset_lang_specifics): New. * tree.c (cp_reset_lang_specifics): New. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/lto-streamer@136592 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.lto | 18 ++++++++++++++ gcc/cp/ChangeLog.lto | 7 ++++++ gcc/cp/cp-objcp-common.h | 2 ++ gcc/cp/cp-tree.h | 1 + gcc/cp/tree.c | 18 ++++++++++++++ gcc/langhooks-def.h | 2 ++ gcc/langhooks.h | 3 +++ gcc/lto-section-out.c | 2 ++ gcc/tree.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/tree.h | 1 + 10 files changed, 115 insertions(+) diff --git a/gcc/ChangeLog.lto b/gcc/ChangeLog.lto index dcdfd37f891..134d844768d 100644 --- a/gcc/ChangeLog.lto +++ b/gcc/ChangeLog.lto @@ -1,3 +1,21 @@ +2008-06-09 Rafael Espindola + based on http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00349.html + + * langhooks-def.h (LANG_HOOKS_RESET_LANG_SPECIFICS): New. + (LANG_HOOKS_INITIALIZER): add LANG_HOOKS_RESET_LANG_SPECIFICS. + * langhooks.h (reset_lang_specifics): New. + * lto-section-out.c (produce_asm_for_decls): Call free_lang_specifics. + * tree.c (uid2type_map): New. + (insert_type_to_uid_type_map): New. + (uid_type_map_eq): New. + (uid_type_map_hash): New. + (init_ttree): Initialize uid2type_map. + (make_node_stat): Call insert_type_to_uid_type_map. + (copy_node_stat): Call insert_type_to_uid_type_map. + (reset_type_lang_specific): New. + (free_lang_specifics): New. + * tree.h (free_lang_specifics) New. + 2008-06-06 Rafael Espindola * Make-lang.in (lto.all.cross): depend on $(LTO_EXE). diff --git a/gcc/cp/ChangeLog.lto b/gcc/cp/ChangeLog.lto index 3e279602716..29bb07440ac 100644 --- a/gcc/cp/ChangeLog.lto +++ b/gcc/cp/ChangeLog.lto @@ -1,3 +1,10 @@ +2008-06-09 Rafael Espindola + based on http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00349.html + + * cp-objcp-common.h (LANG_HOOKS_RESET_LANG_SPECIFICS): New. + * cp-tree.h (cp_reset_lang_specifics): New. + * tree.c (cp_reset_lang_specifics): New. + 2008-04-04 Ollie Wild * class.c (layout_class_type): Rename c_build_bitfield_integer_type to diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index b2b8405fccd..a12ed81e0b0 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -30,6 +30,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, specific to C++ or ObjC++ go in cp/cp-lang.c and objcp/objcp-lang.c, respectively. */ +#undef LANG_HOOKS_RESET_LANG_SPECIFICS +#define LANG_HOOKS_RESET_LANG_SPECIFICS cp_reset_lang_specifics #undef LANG_HOOKS_TREE_SIZE #define LANG_HOOKS_TREE_SIZE cp_tree_size #undef LANG_HOOKS_FINISH diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 0c3d0dd21aa..8e472257ae8 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4684,6 +4684,7 @@ extern tree finish_decltype_type (tree, bool); extern tree finish_trait_expr (enum cp_trait_kind, tree, tree); /* in tree.c */ +void cp_reset_lang_specifics (tree t); extern void lang_check_failed (const char *, int, const char *) ATTRIBUTE_NORETURN; extern tree stabilize_expr (tree, tree *); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ff372206ee6..baefdb2fcf4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2748,6 +2748,24 @@ cast_valid_in_integral_constant_expression_p (tree type) || type == error_mark_node); } +/* Clean the C++ specific parts of the tree T. */ + +void +cp_reset_lang_specifics (tree t) +{ + if (TREE_CODE (t) == METHOD_TYPE + || TREE_CODE (t) == FUNCTION_TYPE) + { + /* Default args are not interesting anymore. */ + tree argtypes = TYPE_ARG_TYPES (t); + while (argtypes) + { + TREE_PURPOSE (argtypes) = 0; + argtypes = TREE_CHAIN (argtypes); + } + } +} + #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) /* Complain that some language-specific thing hanging off a tree diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index aae46406515..6a6866323c8 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -109,6 +109,7 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, #define LANG_HOOKS_DWARF_NAME lhd_dwarf_name #define LANG_HOOKS_GET_CALLEE_FNDECL lhd_return_null_const_tree #define LANG_HOOKS_EXPR_SIZE lhd_expr_size +#define LANG_HOOKS_RESET_LANG_SPECIFICS lhd_do_nothing_t #define LANG_HOOKS_TREE_SIZE lhd_tree_size #define LANG_HOOKS_TYPES_COMPATIBLE_P lhd_types_compatible_p #define LANG_HOOKS_BUILTIN_FUNCTION lhd_builtin_function @@ -226,6 +227,7 @@ extern tree lhd_make_node (enum tree_code); #define LANG_HOOKS_INITIALIZER { \ LANG_HOOKS_NAME, \ LANG_HOOKS_IDENTIFIER_SIZE, \ + LANG_HOOKS_RESET_LANG_SPECIFICS, \ LANG_HOOKS_TREE_SIZE, \ LANG_HOOKS_INIT_OPTIONS, \ LANG_HOOKS_INITIALIZE_DIAGNOSTICS, \ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 6a54b01f060..f37a41dbfdf 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -223,6 +223,9 @@ struct lang_hooks identifier nodes long enough for the language-specific slots. */ size_t identifier_size; + /* Remove any parts of the tree that are used only by the FE. */ + void (*reset_lang_specifics) (tree); + /* Determines the size of any language-specific tcc_constant or tcc_exceptional nodes. Since it is called from make_node, the only information available is the tree code. Expected to die diff --git a/gcc/lto-section-out.c b/gcc/lto-section-out.c index 8095f378e76..d68c76169fe 100644 --- a/gcc/lto-section-out.c +++ b/gcc/lto-section-out.c @@ -585,6 +585,8 @@ produce_asm_for_decls (void) section *decl_section = lto_get_section (LTO_section_decls, NULL); struct output_block *ob = create_output_block (LTO_section_decls); + free_lang_specifics (); + ob->global = true; ob->main_hash_table = htab_create (37, lto_hash_global_slot_node, lto_eq_global_slot_node, free); diff --git a/gcc/tree.c b/gcc/tree.c index bfede0623fe..dbf657b5b31 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -110,6 +110,9 @@ static GTY(()) int next_decl_uid; /* Unique id for next type created. */ static GTY(()) int next_type_uid = 1; +static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node))) + htab_t uid2type_map; + /* Since we cannot rehash a type after it is in the table, we have to keep the hash code. */ @@ -209,6 +212,41 @@ const char * const omp_clause_code_name[] = /* Init tree.c. */ +/* Add tree NODE into the UID2TYPE_MAP hash table. */ + +static void +insert_type_to_uid_type_map (tree node) +{ + void **slot; + struct tree_type key; + + key.uid = TYPE_UID (node); + slot = htab_find_slot_with_hash (uid2type_map, + &key, TYPE_UID (node), INSERT); + + gcc_assert (!*slot); + + *(tree *)slot = node; +} + +/* Compares tree VA and tree VB. */ + +static int +uid_type_map_eq (const void *va, const void *vb) +{ + const_tree a = (const_tree) va; + const_tree b = (const_tree) vb; + return (a->type.uid == b->type.uid); +} + +/* Hash the tree ITEM. */ + +static unsigned int +uid_type_map_hash (const void *item) +{ + return ((const_tree)item)->type.uid; +} + void init_ttree (void) { @@ -231,6 +269,9 @@ init_ttree (void) int_cst_node = make_node (INTEGER_CST); + uid2type_map = htab_create_ggc (4093, uid_type_map_hash, + uid_type_map_eq, NULL); + tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON] = 1; tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_NON_COMMON] = 1; tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON] = 1; @@ -612,6 +653,7 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) /* We have not yet computed the alias set for this type. */ TYPE_ALIAS_SET (t) = -1; + insert_type_to_uid_type_map (t); break; case tcc_constant: @@ -716,6 +758,7 @@ copy_node_stat (tree node MEM_STAT_DECL) TYPE_CACHED_VALUES_P (t) = 0; TYPE_CACHED_VALUES (t) = NULL_TREE; } + insert_type_to_uid_type_map (t); } return t; @@ -3733,6 +3776,24 @@ build_type_attribute_variant (tree ttype, tree attribute) TYPE_QUALS (ttype)); } +/* Helper function of free_lang_specifics. */ + +static int +reset_type_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED) +{ + tree decl = *(tree*)slot; + lang_hooks.reset_lang_specifics (decl); + return 1; +} + +/* Free resources that are used by FE but are not needed once they are done. */ + +void +free_lang_specifics (void) +{ + htab_traverse (uid2type_map, reset_type_lang_specific, NULL); +} + /* Return nonzero if IDENT is a valid name for attribute ATTR, or zero if not. diff --git a/gcc/tree.h b/gcc/tree.h index 4b091d6ac8b..c78c2e64732 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4713,6 +4713,7 @@ function_args_iter_next (function_args_iterator *i) /* In tree.c */ +extern void free_lang_specifics (void); extern unsigned crc32_string (unsigned, const char *); extern void clean_symbol_name (char *); extern tree get_file_function_name (const char *); -- cgit v1.2.3