aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2006-04-11 01:36:50 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2006-04-11 01:36:50 +0000
commit33c9159e09fb29cd6c47e076c6a2006a544884a9 (patch)
tree7d93c2f41a91db2797e82ea2593a73f5c5b9cda7 /gcc/dwarf2out.c
parentab9260ac48d4f7dad156eae570df7ab4f826af7c (diff)
downloadgcc-33c9159e09fb29cd6c47e076c6a2006a544884a9.zip
gcc-33c9159e09fb29cd6c47e076c6a2006a544884a9.tar.gz
gcc-33c9159e09fb29cd6c47e076c6a2006a544884a9.tar.bz2
20060410.c: New.
PR/21391 * testsuite/gcc.dg/20060410.c: New. * dwarf2out.c (struct die_struct): Add die_perennial_p field. (premark_used_types_helper): New. (premark_used_types): New. (gen_subprogram_die): Call premark_used_types. (prune_unused_types_walk): Do not prune perennial dies. * function.c (used_types_insert): New. * function.h (struct function): Add used_types_hash field. (used_types_insert): Add prototype. * Makefile.in (FUNCTION_H): Depend on HASHTAB_H. * c-parser.c (c_parser_cast_expression): Save casted types in used types hash table. From-SVN: r112845
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3a02acf..f7de3d7 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -354,6 +354,7 @@ static void dwarf2out_stack_adjust (rtx, bool);
static void flush_queued_reg_saves (void);
static bool clobbers_queued_reg_save (rtx);
static void dwarf2out_frame_debug_expr (rtx, const char *);
+static void premark_used_types (void);
/* Support for complex CFA locations. */
static void output_cfa_loc (dw_cfi_ref);
@@ -3697,6 +3698,8 @@ typedef struct die_struct GTY(())
dw_offset die_offset;
unsigned long die_abbrev;
int die_mark;
+ /* Die is used and must not be pruned as unused. */
+ int die_perennial_p;
unsigned int decl_id;
}
die_node;
@@ -11511,6 +11514,32 @@ dwarf2out_abstract_function (tree decl)
current_function_decl = save_fn;
}
+/* Helper function of premark_used_types() which gets called through
+ htab_traverse_resize().
+
+ Marks the DIE of a given type in *SLOT as perennial, so it never gets
+ marked as unused by prune_unused_types. */
+static int
+premark_used_types_helper (void **slot, void *data ATTRIBUTE_UNUSED)
+{
+ tree type;
+ dw_die_ref die;
+
+ type = *slot;
+ die = lookup_type_die (type);
+ if (die != NULL)
+ die->die_perennial_p = 1;
+ return 1;
+}
+
+/* Mark all members of used_types_hash as perennial. */
+static void
+premark_used_types (void)
+{
+ if (cfun && cfun->used_types_hash)
+ htab_traverse (cfun->used_types_hash, premark_used_types_helper, NULL);
+}
+
/* Generate a DIE to represent a declared function (either file-scope or
block-local). */
@@ -11526,6 +11555,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
int declaration = (current_function_decl != decl
|| class_or_namespace_scope_p (context_die));
+ premark_used_types();
+
/* It is possible to have both DECL_ABSTRACT and DECLARATION be true if we
started to generate the abstract instance of an inline, decided to output
its containing class, and proceeded to emit the declaration of the inline
@@ -13965,6 +13996,9 @@ prune_unused_types_walk (dw_die_ref die)
case DW_TAG_subrange_type:
case DW_TAG_ptr_to_member_type:
case DW_TAG_file_type:
+ if (die->die_perennial_p)
+ break;
+
/* It's a type node --- don't mark it. */
return;