Mercurial > hg > CbC > CbC_gcc
diff gcc/function.c @ 36:855418dad1a3
gcc-4.4-20091020
author | e075725 |
---|---|
date | Tue, 22 Dec 2009 21:19:31 +0900 |
parents | 58ad6c70ea60 |
children | 27e6f95b2c21 3bfb6c00c1e0 |
line wrap: on
line diff
--- a/gcc/function.c Thu Sep 24 13:21:57 2009 +0900 +++ b/gcc/function.c Tue Dec 22 21:19:31 2009 +0900 @@ -132,6 +132,10 @@ in this function. */ static VEC(int,heap) *sibcall_epilogue; + +htab_t types_used_by_vars_hash = NULL; +tree types_used_by_cur_var_decl = NULL; + /* Forward declarations. */ static struct temp_slot *find_temp_slot_from_address (rtx); @@ -5372,6 +5376,7 @@ } /* Insert a TYPE into the used types hash table of CFUN. */ + static void used_types_insert_helper (tree type, struct function *func) { @@ -5396,7 +5401,81 @@ t = TREE_TYPE (t); t = TYPE_MAIN_VARIANT (t); if (debug_info_level > DINFO_LEVEL_NONE) - used_types_insert_helper (t, cfun); + { + if (cfun) + used_types_insert_helper (t, cfun); + else + /* So this might be a type referenced by a global variable. + Record that type so that we can later decide to emit its debug + information. */ + types_used_by_cur_var_decl = + tree_cons (t, NULL, types_used_by_cur_var_decl); + + } +} + +/* Helper to Hash a struct types_used_by_vars_entry. */ + +static hashval_t +hash_types_used_by_vars_entry (const struct types_used_by_vars_entry *entry) +{ + gcc_assert (entry && entry->var_decl && entry->type); + + return iterative_hash_object (entry->type, + iterative_hash_object (entry->var_decl, 0)); +} + +/* Hash function of the types_used_by_vars_entry hash table. */ + +hashval_t +types_used_by_vars_do_hash (const void *x) +{ + const struct types_used_by_vars_entry *entry = + (const struct types_used_by_vars_entry *) x; + + return hash_types_used_by_vars_entry (entry); +} + +/*Equality function of the types_used_by_vars_entry hash table. */ + +int +types_used_by_vars_eq (const void *x1, const void *x2) +{ + const struct types_used_by_vars_entry *e1 = + (const struct types_used_by_vars_entry *) x1; + const struct types_used_by_vars_entry *e2 = + (const struct types_used_by_vars_entry *)x2; + + return (e1->var_decl == e2->var_decl && e1->type == e2->type); +} + +/* Inserts an entry into the types_used_by_vars_hash hash table. */ + +void +types_used_by_var_decl_insert (tree type, tree var_decl) +{ + if (type != NULL && var_decl != NULL) + { + void **slot; + struct types_used_by_vars_entry e; + e.var_decl = var_decl; + e.type = type; + if (types_used_by_vars_hash == NULL) + types_used_by_vars_hash = + htab_create_ggc (37, types_used_by_vars_do_hash, + types_used_by_vars_eq, NULL); + slot = htab_find_slot_with_hash (types_used_by_vars_hash, &e, + hash_types_used_by_vars_entry (&e), INSERT); + if (*slot == NULL) + { + struct types_used_by_vars_entry *entry; + entry = (struct types_used_by_vars_entry*) ggc_alloc + (sizeof (struct types_used_by_vars_entry)); + entry->type = type; + entry->var_decl = var_decl; + *slot = entry; + } + } } struct rtl_opt_pass pass_leaf_regs =