summaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2009-09-23 16:07:13 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2009-09-23 16:07:13 +0000
commit1a4c44c530a88024d10331a5213363152ff3d0fa (patch)
tree716216bf133fc60984e49edb258a912ca31ba3e8 /gcc/function.c
parenteb241fe973b9160a1e25228289aee69476677da6 (diff)
downloadgcc-1a4c44c530a88024d10331a5213363152ff3d0fa.tar.gz
Fix PR debug/41065
gcc/ChangeLog: PR debug/41065 * function.h (types_used_by_vars_hash): Declare new hash table. (types_used_by_vars_eq, types_used_by_var_decl_insert): Declare equality and hash function for the hash table. (types_used_by_cur_var_decl): Declare a new global chained list. (types_used_by_var_decl_insert): Declare new function. * function.c (types_used_by_vars_hash): Define the hashtable ... (types_used_by_vars_eq, types_used_by_vars_do_hash): ... as well as its equality and hash functions. (hash_types_used_by_vars_entry): New hash helper. (types_used_by_cur_var_decl): Define the global chained list. (used_types_insert): Update the list of types used by the global variable being parsed. (types_used_by_var_decl_insert): Define new function. * c-common.h (record_types_used_by_current_var_decl): Declare ... * c-common.c (record_types_used_by_current_var_decl): ... new function. * c-decl.c (finish_decl): Record the types used by the global variable declaration we've just parsed. * dwarf2out.c (premark_used_types): Insert a new line between comment and function. (premark_used_types_helper): Fix comment. (premark_types_used_by_global_vars_helper, premark_types_used_by_global_vars): New functions. (prune_unused_types): Do not prune types used by global variables. gcc/cp/ChangeLog: PR debug/41065 * decl.c (cp_finish_decl): Record the types used by the global variable declaration we've just parsed. gcc/testsuite/ChangeLog: PR debug/41065 * gcc.dg/debug/dwarf2/global-used-types.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152085 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c81
1 files changed, 80 insertions, 1 deletions
diff --git a/gcc/function.c b/gcc/function.c
index 6c9bea842e9..aaed57a5de1 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -130,6 +130,10 @@ static GTY((if_marked ("ggc_marked_p"), param_is (struct rtx_def)))
static GTY((if_marked ("ggc_marked_p"), param_is (struct rtx_def)))
htab_t epilogue_insn_hash;
+
+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);
@@ -5426,6 +5430,7 @@ rest_of_handle_check_leaf_regs (void)
}
/* Insert a TYPE into the used types hash table of CFUN. */
+
static void
used_types_insert_helper (tree type, struct function *func)
{
@@ -5450,7 +5455,81 @@ used_types_insert (tree t)
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 =