Commit 1a27722f by Geoffrey Keating Committed by Geoffrey Keating

dwarf2out.c (struct dw_attr_struct): Remove dw_attr_next.

	* dwarf2out.c (struct dw_attr_struct): Remove dw_attr_next.
	Declare VECs of this type.
	(struct die_struct): Make field die_attr a VEC of dw_attr_struct.
	(remove_children): Delete.
	(add_dwarf_attr): Use VEC routines.
	(add_AT_flag): Update for changes to add_dwarf_attr.
	(add_AT_int): Likewise.
	(add_AT_unsigned): Likewise.
	(add_AT_long_long): Likewise.
	(add_AT_vec): Likewise.
	(add_AT_string): Likewise.
	(add_AT_die_ref): Likewise.
	(add_AT_fde_ref): Likewise.
	(add_AT_loc): Likewise.
	(add_AT_loc_list): Likewise.
	(add_AT_addr): Likewise.
	(add_AT_lbl_id): Likewise.
	(add_AT_lineptr): Likewise.
	(add_AT_macptr): Likewise.
	(add_AT_offset): Likewise.
	(add_AT_range_list): Likewise.
	(get_AT): Use VEC_iterate.
	(remove_AT): Use VEC_ordered_remove.
	(free_die): Fold remove_children into here; have it use VEC_iterate.
	(print_die): Use VEC_iterate on attrs.
	(reverse_die_lists): Don't reverse attr lists.
	(die_checksum): Use VEC_iterate on attrs.
	(same_die_p): Likewise.
	(output_location_lists): Likewise.
	(build_abbrev_table): Likewise.
	(size_of_die): Likewise.
	(unmark_all_dies): Likewise.
	(output_abbrev_section): Likewise.
	(output_die): Likewise.
	(prune_unused_types_walk_attribs): Likewise.

From-SVN: r112829
parent e92857a1
2006-04-10 Geoffrey Keating <geoffk@apple.com>
* dwarf2out.c (struct dw_attr_struct): Remove dw_attr_next.
Declare VECs of this type.
(struct die_struct): Make field die_attr a VEC of dw_attr_struct.
(remove_children): Delete.
(add_dwarf_attr): Use VEC routines.
(add_AT_flag): Update for changes to add_dwarf_attr.
(add_AT_int): Likewise.
(add_AT_unsigned): Likewise.
(add_AT_long_long): Likewise.
(add_AT_vec): Likewise.
(add_AT_string): Likewise.
(add_AT_die_ref): Likewise.
(add_AT_fde_ref): Likewise.
(add_AT_loc): Likewise.
(add_AT_loc_list): Likewise.
(add_AT_addr): Likewise.
(add_AT_lbl_id): Likewise.
(add_AT_lineptr): Likewise.
(add_AT_macptr): Likewise.
(add_AT_offset): Likewise.
(add_AT_range_list): Likewise.
(get_AT): Use VEC_iterate.
(remove_AT): Use VEC_ordered_remove.
(free_die): Fold remove_children into here; have it use VEC_iterate.
(print_die): Use VEC_iterate on attrs.
(reverse_die_lists): Don't reverse attr lists.
(die_checksum): Use VEC_iterate on attrs.
(same_die_p): Likewise.
(output_location_lists): Likewise.
(build_abbrev_table): Likewise.
(size_of_die): Likewise.
(unmark_all_dies): Likewise.
(output_abbrev_section): Likewise.
(output_die): Likewise.
(prune_unused_types_walk_attribs): Likewise.
2006-04-10 Eric Botcazou <ebotcazou@libertysurf.fr> 2006-04-10 Eric Botcazou <ebotcazou@libertysurf.fr>
* doc/install.texi (*-*-solaris2*): Point to the configure page. * doc/install.texi (*-*-solaris2*): Point to the configure page.
......
...@@ -3676,18 +3676,20 @@ dw_separate_line_info_entry; ...@@ -3676,18 +3676,20 @@ dw_separate_line_info_entry;
typedef struct dw_attr_struct GTY(()) typedef struct dw_attr_struct GTY(())
{ {
enum dwarf_attribute dw_attr; enum dwarf_attribute dw_attr;
dw_attr_ref dw_attr_next;
dw_val_node dw_attr_val; dw_val_node dw_attr_val;
} }
dw_attr_node; dw_attr_node;
DEF_VEC_O(dw_attr_node);
DEF_VEC_ALLOC_O(dw_attr_node,gc);
/* The Debugging Information Entry (DIE) structure */ /* The Debugging Information Entry (DIE) structure */
typedef struct die_struct GTY(()) typedef struct die_struct GTY(())
{ {
enum dwarf_tag die_tag; enum dwarf_tag die_tag;
char *die_symbol; char *die_symbol;
dw_attr_ref die_attr; VEC(dw_attr_node,gc) * die_attr;
dw_die_ref die_parent; dw_die_ref die_parent;
dw_die_ref die_child; dw_die_ref die_child;
dw_die_ref die_sib; dw_die_ref die_sib;
...@@ -4019,7 +4021,6 @@ static bool is_ada (void); ...@@ -4019,7 +4021,6 @@ static bool is_ada (void);
static void remove_AT (dw_die_ref, enum dwarf_attribute); static void remove_AT (dw_die_ref, enum dwarf_attribute);
static void remove_child_TAG (dw_die_ref, enum dwarf_tag); static void remove_child_TAG (dw_die_ref, enum dwarf_tag);
static inline void free_die (dw_die_ref); static inline void free_die (dw_die_ref);
static void remove_children (dw_die_ref);
static void add_child_die (dw_die_ref, dw_die_ref); static void add_child_die (dw_die_ref, dw_die_ref);
static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree); static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
static dw_die_ref lookup_type_die (tree); static dw_die_ref lookup_type_die (tree);
...@@ -4837,11 +4838,13 @@ decl_class_context (tree decl) ...@@ -4837,11 +4838,13 @@ decl_class_context (tree decl)
static inline void static inline void
add_dwarf_attr (dw_die_ref die, dw_attr_ref attr) add_dwarf_attr (dw_die_ref die, dw_attr_ref attr)
{ {
if (die != NULL && attr != NULL) /* Maybe this should be an assert? */
{ if (die == NULL)
attr->dw_attr_next = die->die_attr; return;
die->die_attr = attr;
} if (die->die_attr == NULL)
die->die_attr = VEC_alloc (dw_attr_node, gc, 1);
VEC_safe_push (dw_attr_node, gc, die->die_attr, attr);
} }
static inline enum dw_val_class static inline enum dw_val_class
...@@ -4855,13 +4858,12 @@ AT_class (dw_attr_ref a) ...@@ -4855,13 +4858,12 @@ AT_class (dw_attr_ref a)
static inline void static inline void
add_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int flag) add_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int flag)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_flag;
attr->dw_attr_val.val_class = dw_val_class_flag; attr.dw_attr_val.v.val_flag = flag;
attr->dw_attr_val.v.val_flag = flag; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline unsigned static inline unsigned
...@@ -4876,13 +4878,12 @@ AT_flag (dw_attr_ref a) ...@@ -4876,13 +4878,12 @@ AT_flag (dw_attr_ref a)
static inline void static inline void
add_AT_int (dw_die_ref die, enum dwarf_attribute attr_kind, HOST_WIDE_INT int_val) add_AT_int (dw_die_ref die, enum dwarf_attribute attr_kind, HOST_WIDE_INT int_val)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_const;
attr->dw_attr_val.val_class = dw_val_class_const; attr.dw_attr_val.v.val_int = int_val;
attr->dw_attr_val.v.val_int = int_val; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline HOST_WIDE_INT static inline HOST_WIDE_INT
...@@ -4898,13 +4899,12 @@ static inline void ...@@ -4898,13 +4899,12 @@ static inline void
add_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned HOST_WIDE_INT unsigned_val) unsigned HOST_WIDE_INT unsigned_val)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_unsigned_const;
attr->dw_attr_val.val_class = dw_val_class_unsigned_const; attr.dw_attr_val.v.val_unsigned = unsigned_val;
attr->dw_attr_val.v.val_unsigned = unsigned_val; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline unsigned HOST_WIDE_INT static inline unsigned HOST_WIDE_INT
...@@ -4920,14 +4920,13 @@ static inline void ...@@ -4920,14 +4920,13 @@ static inline void
add_AT_long_long (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_long_long (dw_die_ref die, enum dwarf_attribute attr_kind,
long unsigned int val_hi, long unsigned int val_low) long unsigned int val_hi, long unsigned int val_low)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_long_long;
attr->dw_attr_val.val_class = dw_val_class_long_long; attr.dw_attr_val.v.val_long_long.hi = val_hi;
attr->dw_attr_val.v.val_long_long.hi = val_hi; attr.dw_attr_val.v.val_long_long.low = val_low;
attr->dw_attr_val.v.val_long_long.low = val_low; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add a floating point attribute value to a DIE and return it. */ /* Add a floating point attribute value to a DIE and return it. */
...@@ -4936,15 +4935,14 @@ static inline void ...@@ -4936,15 +4935,14 @@ static inline void
add_AT_vec (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_vec (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned int length, unsigned int elt_size, unsigned char *array) unsigned int length, unsigned int elt_size, unsigned char *array)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_vec;
attr->dw_attr_val.val_class = dw_val_class_vec; attr.dw_attr_val.v.val_vec.length = length;
attr->dw_attr_val.v.val_vec.length = length; attr.dw_attr_val.v.val_vec.elt_size = elt_size;
attr->dw_attr_val.v.val_vec.elt_size = elt_size; attr.dw_attr_val.v.val_vec.array = array;
attr->dw_attr_val.v.val_vec.array = array; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Hash and equality functions for debug_str_hash. */ /* Hash and equality functions for debug_str_hash. */
...@@ -4967,7 +4965,7 @@ debug_str_eq (const void *x1, const void *x2) ...@@ -4967,7 +4965,7 @@ debug_str_eq (const void *x1, const void *x2)
static inline void static inline void
add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str) add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
struct indirect_string_node *node; struct indirect_string_node *node;
void **slot; void **slot;
...@@ -4983,11 +4981,10 @@ add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str) ...@@ -4983,11 +4981,10 @@ add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str)
node->str = ggc_strdup (str); node->str = ggc_strdup (str);
node->refcount++; node->refcount++;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_str;
attr->dw_attr_val.val_class = dw_val_class_str; attr.dw_attr_val.v.val_str = node;
attr->dw_attr_val.v.val_str = node; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline const char * static inline const char *
...@@ -5039,14 +5036,13 @@ AT_string_form (dw_attr_ref a) ...@@ -5039,14 +5036,13 @@ AT_string_form (dw_attr_ref a)
static inline void static inline void
add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die) add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_die_ref;
attr->dw_attr_val.val_class = dw_val_class_die_ref; attr.dw_attr_val.v.val_die_ref.die = targ_die;
attr->dw_attr_val.v.val_die_ref.die = targ_die; attr.dw_attr_val.v.val_die_ref.external = 0;
attr->dw_attr_val.v.val_die_ref.external = 0; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add an AT_specification attribute to a DIE, and also make the back /* Add an AT_specification attribute to a DIE, and also make the back
...@@ -5088,13 +5084,12 @@ set_AT_ref_external (dw_attr_ref a, int i) ...@@ -5088,13 +5084,12 @@ set_AT_ref_external (dw_attr_ref a, int i)
static inline void static inline void
add_AT_fde_ref (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int targ_fde) add_AT_fde_ref (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int targ_fde)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_fde_ref;
attr->dw_attr_val.val_class = dw_val_class_fde_ref; attr.dw_attr_val.v.val_fde_index = targ_fde;
attr->dw_attr_val.v.val_fde_index = targ_fde; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add a location description attribute value to a DIE. */ /* Add a location description attribute value to a DIE. */
...@@ -5102,13 +5097,12 @@ add_AT_fde_ref (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int tar ...@@ -5102,13 +5097,12 @@ add_AT_fde_ref (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int tar
static inline void static inline void
add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc) add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_loc;
attr->dw_attr_val.val_class = dw_val_class_loc; attr.dw_attr_val.v.val_loc = loc;
attr->dw_attr_val.v.val_loc = loc; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline dw_loc_descr_ref static inline dw_loc_descr_ref
...@@ -5121,13 +5115,12 @@ AT_loc (dw_attr_ref a) ...@@ -5121,13 +5115,12 @@ AT_loc (dw_attr_ref a)
static inline void static inline void
add_AT_loc_list (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_list_ref loc_list) add_AT_loc_list (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_list_ref loc_list)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_loc_list;
attr->dw_attr_val.val_class = dw_val_class_loc_list; attr.dw_attr_val.v.val_loc_list = loc_list;
attr->dw_attr_val.v.val_loc_list = loc_list; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
have_location_lists = true; have_location_lists = true;
} }
...@@ -5143,13 +5136,12 @@ AT_loc_list (dw_attr_ref a) ...@@ -5143,13 +5136,12 @@ AT_loc_list (dw_attr_ref a)
static inline void static inline void
add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr) add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_addr;
attr->dw_attr_val.val_class = dw_val_class_addr; attr.dw_attr_val.v.val_addr = addr;
attr->dw_attr_val.v.val_addr = addr; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline rtx static inline rtx
...@@ -5164,13 +5156,12 @@ AT_addr (dw_attr_ref a) ...@@ -5164,13 +5156,12 @@ AT_addr (dw_attr_ref a)
static inline void static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind, const char *lbl_id) add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind, const char *lbl_id)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr->dw_attr_val.val_class = dw_val_class_lbl_id; attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
attr->dw_attr_val.v.val_lbl_id = xstrdup (lbl_id); add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add a section offset attribute value to a DIE, an offset into the /* Add a section offset attribute value to a DIE, an offset into the
...@@ -5180,13 +5171,12 @@ static inline void ...@@ -5180,13 +5171,12 @@ static inline void
add_AT_lineptr (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_lineptr (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *label) const char *label)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_lineptr;
attr->dw_attr_val.val_class = dw_val_class_lineptr; attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
attr->dw_attr_val.v.val_lbl_id = xstrdup (label); add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add a section offset attribute value to a DIE, an offset into the /* Add a section offset attribute value to a DIE, an offset into the
...@@ -5196,13 +5186,12 @@ static inline void ...@@ -5196,13 +5186,12 @@ static inline void
add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *label) const char *label)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_macptr;
attr->dw_attr_val.val_class = dw_val_class_macptr; attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
attr->dw_attr_val.v.val_lbl_id = xstrdup (label); add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add an offset attribute value to a DIE. */ /* Add an offset attribute value to a DIE. */
...@@ -5211,13 +5200,12 @@ static inline void ...@@ -5211,13 +5200,12 @@ static inline void
add_AT_offset (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_offset (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned HOST_WIDE_INT offset) unsigned HOST_WIDE_INT offset)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_offset;
attr->dw_attr_val.val_class = dw_val_class_offset; attr.dw_attr_val.v.val_offset = offset;
attr->dw_attr_val.v.val_offset = offset; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
/* Add an range_list attribute value to a DIE. */ /* Add an range_list attribute value to a DIE. */
...@@ -5226,13 +5214,12 @@ static void ...@@ -5226,13 +5214,12 @@ static void
add_AT_range_list (dw_die_ref die, enum dwarf_attribute attr_kind, add_AT_range_list (dw_die_ref die, enum dwarf_attribute attr_kind,
long unsigned int offset) long unsigned int offset)
{ {
dw_attr_ref attr = ggc_alloc (sizeof (dw_attr_node)); dw_attr_node attr;
attr->dw_attr_next = NULL; attr.dw_attr = attr_kind;
attr->dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_range_list;
attr->dw_attr_val.val_class = dw_val_class_range_list; attr.dw_attr_val.v.val_offset = offset;
attr->dw_attr_val.v.val_offset = offset; add_dwarf_attr (die, &attr);
add_dwarf_attr (die, attr);
} }
static inline const char * static inline const char *
...@@ -5250,11 +5237,13 @@ static dw_attr_ref ...@@ -5250,11 +5237,13 @@ static dw_attr_ref
get_AT (dw_die_ref die, enum dwarf_attribute attr_kind) get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{ {
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
dw_die_ref spec = NULL; dw_die_ref spec = NULL;
if (die != NULL) if (! die)
{ return NULL;
for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
if (a->dw_attr == attr_kind) if (a->dw_attr == attr_kind)
return a; return a;
else if (a->dw_attr == DW_AT_specification else if (a->dw_attr == DW_AT_specification
...@@ -5263,7 +5252,6 @@ get_AT (dw_die_ref die, enum dwarf_attribute attr_kind) ...@@ -5263,7 +5252,6 @@ get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
if (spec) if (spec)
return get_AT (spec, attr_kind); return get_AT (spec, attr_kind);
}
return NULL; return NULL;
} }
...@@ -5403,21 +5391,20 @@ free_AT (dw_attr_ref a) ...@@ -5403,21 +5391,20 @@ free_AT (dw_attr_ref a)
static void static void
remove_AT (dw_die_ref die, enum dwarf_attribute attr_kind) remove_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{ {
dw_attr_ref *p; dw_attr_ref a;
dw_attr_ref removed = NULL; unsigned ix;
if (die != NULL) if (! die)
{ return;
for (p = &(die->die_attr); *p; p = &((*p)->dw_attr_next))
if ((*p)->dw_attr == attr_kind)
{
removed = *p;
*p = (*p)->dw_attr_next;
break;
}
if (removed != 0) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
free_AT (removed); if (a->dw_attr == attr_kind)
{
free_AT (a);
/* VEC_ordered_remove should help reduce the number of abbrevs
that are needed. */
VEC_ordered_remove (dw_attr_node, die->die_attr, ix);
return;
} }
} }
...@@ -5449,18 +5436,13 @@ remove_child_TAG (dw_die_ref die, enum dwarf_tag tag) ...@@ -5449,18 +5436,13 @@ remove_child_TAG (dw_die_ref die, enum dwarf_tag tag)
} }
} }
/* Free up the memory used by DIE. */ /* Free up the memory used by DIE, by removing its children and
anything associated with its attributes. DIEs are garbage
static inline void collected, so there is no actual freeing to do; the only real work is
free_die (dw_die_ref die) to decrease string reference counts. */
{
remove_children (die);
}
/* Discard the children of this DIE. */
static void static void
remove_children (dw_die_ref die) free_die (dw_die_ref die)
{ {
dw_die_ref child_die = die->die_child; dw_die_ref child_die = die->die_child;
...@@ -5470,16 +5452,12 @@ remove_children (dw_die_ref die) ...@@ -5470,16 +5452,12 @@ remove_children (dw_die_ref die)
{ {
dw_die_ref tmp_die = child_die; dw_die_ref tmp_die = child_die;
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
child_die = child_die->die_sib; child_die = child_die->die_sib;
for (a = tmp_die->die_attr; a != NULL;) for (ix = 0; VEC_iterate (dw_attr_node, tmp_die->die_attr, ix, a); ix++)
{ free_AT (a);
dw_attr_ref tmp_a = a;
a = a->dw_attr_next;
free_AT (tmp_a);
}
free_die (tmp_die); free_die (tmp_die);
} }
...@@ -5698,6 +5676,7 @@ print_die (dw_die_ref die, FILE *outfile) ...@@ -5698,6 +5676,7 @@ print_die (dw_die_ref die, FILE *outfile)
{ {
dw_attr_ref a; dw_attr_ref a;
dw_die_ref c; dw_die_ref c;
unsigned ix;
print_spaces (outfile); print_spaces (outfile);
fprintf (outfile, "DIE %4lu: %s\n", fprintf (outfile, "DIE %4lu: %s\n",
...@@ -5706,7 +5685,7 @@ print_die (dw_die_ref die, FILE *outfile) ...@@ -5706,7 +5685,7 @@ print_die (dw_die_ref die, FILE *outfile)
fprintf (outfile, " abbrev id: %lu", die->die_abbrev); fprintf (outfile, " abbrev id: %lu", die->die_abbrev);
fprintf (outfile, " offset: %lu\n", die->die_offset); fprintf (outfile, " offset: %lu\n", die->die_offset);
for (a = die->die_attr; a != NULL; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{ {
print_spaces (outfile); print_spaces (outfile);
fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr)); fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr));
...@@ -5838,16 +5817,6 @@ static void ...@@ -5838,16 +5817,6 @@ static void
reverse_die_lists (dw_die_ref die) reverse_die_lists (dw_die_ref die)
{ {
dw_die_ref c, cp, cn; dw_die_ref c, cp, cn;
dw_attr_ref a, ap, an;
for (a = die->die_attr, ap = 0; a; a = an)
{
an = a->dw_attr_next;
a->dw_attr_next = ap;
ap = a;
}
die->die_attr = ap;
for (c = die->die_child, cp = 0; c; c = cn) for (c = die->die_child, cp = 0; c; c = cn)
{ {
...@@ -5989,6 +5958,7 @@ die_checksum (dw_die_ref die, struct md5_ctx *ctx, int *mark) ...@@ -5989,6 +5958,7 @@ die_checksum (dw_die_ref die, struct md5_ctx *ctx, int *mark)
{ {
dw_die_ref c; dw_die_ref c;
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
/* To avoid infinite recursion. */ /* To avoid infinite recursion. */
if (die->die_mark) if (die->die_mark)
...@@ -6000,7 +5970,7 @@ die_checksum (dw_die_ref die, struct md5_ctx *ctx, int *mark) ...@@ -6000,7 +5970,7 @@ die_checksum (dw_die_ref die, struct md5_ctx *ctx, int *mark)
CHECKSUM (die->die_tag); CHECKSUM (die->die_tag);
for (a = die->die_attr; a; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
attr_checksum (a, ctx, mark); attr_checksum (a, ctx, mark);
for (c = die->die_child; c; c = c->die_sib) for (c = die->die_child; c; c = c->die_sib)
...@@ -6108,7 +6078,8 @@ static int ...@@ -6108,7 +6078,8 @@ static int
same_die_p (dw_die_ref die1, dw_die_ref die2, int *mark) same_die_p (dw_die_ref die1, dw_die_ref die2, int *mark)
{ {
dw_die_ref c1, c2; dw_die_ref c1, c2;
dw_attr_ref a1, a2; dw_attr_ref a1;
unsigned ix;
/* To avoid infinite recursion. */ /* To avoid infinite recursion. */
if (die1->die_mark) if (die1->die_mark)
...@@ -6118,12 +6089,12 @@ same_die_p (dw_die_ref die1, dw_die_ref die2, int *mark) ...@@ -6118,12 +6089,12 @@ same_die_p (dw_die_ref die1, dw_die_ref die2, int *mark)
if (die1->die_tag != die2->die_tag) if (die1->die_tag != die2->die_tag)
return 0; return 0;
for (a1 = die1->die_attr, a2 = die2->die_attr; if (VEC_length (dw_attr_node, die1->die_attr)
a1 && a2; != VEC_length (dw_attr_node, die2->die_attr))
a1 = a1->dw_attr_next, a2 = a2->dw_attr_next)
if (!same_attr_p (a1, a2, mark))
return 0; return 0;
if (a1 || a2)
for (ix = 0; VEC_iterate (dw_attr_node, die1->die_attr, ix, a1); ix++)
if (!same_attr_p (a1, VEC_index (dw_attr_node, die2->die_attr, ix), mark))
return 0; return 0;
for (c1 = die1->die_child, c2 = die2->die_child; for (c1 = die1->die_child, c2 = die2->die_child;
...@@ -6486,11 +6457,12 @@ static void ...@@ -6486,11 +6457,12 @@ static void
output_location_lists (dw_die_ref die) output_location_lists (dw_die_ref die)
{ {
dw_die_ref c; dw_die_ref c;
dw_attr_ref d_attr; dw_attr_ref a;
unsigned ix;
for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
if (AT_class (d_attr) == dw_val_class_loc_list) if (AT_class (a) == dw_val_class_loc_list)
output_loc_list (AT_loc_list (d_attr)); output_loc_list (AT_loc_list (a));
for (c = die->die_child; c != NULL; c = c->die_sib) for (c = die->die_child; c != NULL; c = c->die_sib)
output_location_lists (c); output_location_lists (c);
...@@ -6508,44 +6480,48 @@ build_abbrev_table (dw_die_ref die) ...@@ -6508,44 +6480,48 @@ build_abbrev_table (dw_die_ref die)
unsigned long abbrev_id; unsigned long abbrev_id;
unsigned int n_alloc; unsigned int n_alloc;
dw_die_ref c; dw_die_ref c;
dw_attr_ref d_attr, a_attr; dw_attr_ref a;
unsigned ix;
/* Scan the DIE references, and mark as external any that refer to /* Scan the DIE references, and mark as external any that refer to
DIEs from other CUs (i.e. those which are not marked). */ DIEs from other CUs (i.e. those which are not marked). */
for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
if (AT_class (d_attr) == dw_val_class_die_ref if (AT_class (a) == dw_val_class_die_ref
&& AT_ref (d_attr)->die_mark == 0) && AT_ref (a)->die_mark == 0)
{ {
gcc_assert (AT_ref (d_attr)->die_symbol); gcc_assert (AT_ref (a)->die_symbol);
set_AT_ref_external (d_attr, 1); set_AT_ref_external (a, 1);
} }
for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id) for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
{ {
dw_die_ref abbrev = abbrev_die_table[abbrev_id]; dw_die_ref abbrev = abbrev_die_table[abbrev_id];
dw_attr_ref die_a, abbrev_a;
unsigned ix;
bool ok = true;
if (abbrev->die_tag == die->die_tag) if (abbrev->die_tag != die->die_tag)
{ continue;
if ((abbrev->die_child != NULL) == (die->die_child != NULL)) if ((abbrev->die_child != NULL) != (die->die_child != NULL))
{ continue;
a_attr = abbrev->die_attr;
d_attr = die->die_attr;
while (a_attr != NULL && d_attr != NULL)
{
if ((a_attr->dw_attr != d_attr->dw_attr)
|| (value_format (a_attr) != value_format (d_attr)))
break;
a_attr = a_attr->dw_attr_next; if (VEC_length (dw_attr_node, abbrev->die_attr)
d_attr = d_attr->dw_attr_next; != VEC_length (dw_attr_node, die->die_attr))
} continue;
if (a_attr == NULL && d_attr == NULL) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, die_a); ix++)
{
abbrev_a = VEC_index (dw_attr_node, abbrev->die_attr, ix);
if ((abbrev_a->dw_attr != die_a->dw_attr)
|| (value_format (abbrev_a) != value_format (die_a)))
{
ok = false;
break; break;
} }
} }
if (ok)
break;
} }
if (abbrev_id >= abbrev_die_table_in_use) if (abbrev_id >= abbrev_die_table_in_use)
...@@ -6596,9 +6572,10 @@ size_of_die (dw_die_ref die) ...@@ -6596,9 +6572,10 @@ size_of_die (dw_die_ref die)
{ {
unsigned long size = 0; unsigned long size = 0;
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
size += size_of_uleb128 (die->die_abbrev); size += size_of_uleb128 (die->die_abbrev);
for (a = die->die_attr; a != NULL; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{ {
switch (AT_class (a)) switch (AT_class (a))
{ {
...@@ -6728,6 +6705,7 @@ unmark_all_dies (dw_die_ref die) ...@@ -6728,6 +6705,7 @@ unmark_all_dies (dw_die_ref die)
{ {
dw_die_ref c; dw_die_ref c;
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
if (!die->die_mark) if (!die->die_mark)
return; return;
...@@ -6736,7 +6714,7 @@ unmark_all_dies (dw_die_ref die) ...@@ -6736,7 +6714,7 @@ unmark_all_dies (dw_die_ref die)
for (c = die->die_child; c; c = c->die_sib) for (c = die->die_child; c; c = c->die_sib)
unmark_all_dies (c); unmark_all_dies (c);
for (a = die->die_attr; a; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
if (AT_class (a) == dw_val_class_die_ref) if (AT_class (a) == dw_val_class_die_ref)
unmark_all_dies (AT_ref (a)); unmark_all_dies (AT_ref (a));
} }
...@@ -6870,11 +6848,11 @@ output_abbrev_section (void) ...@@ -6870,11 +6848,11 @@ output_abbrev_section (void)
{ {
unsigned long abbrev_id; unsigned long abbrev_id;
dw_attr_ref a_attr;
for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id) for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
{ {
dw_die_ref abbrev = abbrev_die_table[abbrev_id]; dw_die_ref abbrev = abbrev_die_table[abbrev_id];
unsigned ix;
dw_attr_ref a_attr;
dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)"); dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)", dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
...@@ -6885,8 +6863,8 @@ output_abbrev_section (void) ...@@ -6885,8 +6863,8 @@ output_abbrev_section (void)
else else
dw2_asm_output_data (1, DW_children_no, "DW_children_no"); dw2_asm_output_data (1, DW_children_no, "DW_children_no");
for (a_attr = abbrev->die_attr; a_attr != NULL; for (ix = 0; VEC_iterate (dw_attr_node, abbrev->die_attr, ix, a_attr);
a_attr = a_attr->dw_attr_next) ix++)
{ {
dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)", dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
dwarf_attr_name (a_attr->dw_attr)); dwarf_attr_name (a_attr->dw_attr));
...@@ -7030,6 +7008,7 @@ output_die (dw_die_ref die) ...@@ -7030,6 +7008,7 @@ output_die (dw_die_ref die)
dw_attr_ref a; dw_attr_ref a;
dw_die_ref c; dw_die_ref c;
unsigned long size; unsigned long size;
unsigned ix;
/* If someone in another CU might refer to us, set up a symbol for /* If someone in another CU might refer to us, set up a symbol for
them to point to. */ them to point to. */
...@@ -7039,7 +7018,7 @@ output_die (dw_die_ref die) ...@@ -7039,7 +7018,7 @@ output_die (dw_die_ref die)
dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (0x%lx) %s)", dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (0x%lx) %s)",
die->die_offset, dwarf_tag_name (die->die_tag)); die->die_offset, dwarf_tag_name (die->die_tag));
for (a = die->die_attr; a != NULL; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{ {
const char *name = dwarf_attr_name (a->dw_attr); const char *name = dwarf_attr_name (a->dw_attr);
...@@ -13888,8 +13867,9 @@ static void ...@@ -13888,8 +13867,9 @@ static void
prune_unused_types_walk_attribs (dw_die_ref die) prune_unused_types_walk_attribs (dw_die_ref die)
{ {
dw_attr_ref a; dw_attr_ref a;
unsigned ix;
for (a = die->die_attr; a != NULL; a = a->dw_attr_next) for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{ {
if (a->dw_attr_val.val_class == dw_val_class_die_ref) if (a->dw_attr_val.val_class == dw_val_class_die_ref)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment