dwarves: find holes when adding a fresh compile unit
To take advantage of cache effects and to avoid calling cu__find_holes more than once on the same struct. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
5f606ab5e3
commit
b902f563b3
2
codiff.c
2
codiff.c
|
@ -258,8 +258,6 @@ static void diff_struct(const struct cu *new_cu, struct class *structure,
|
|||
|
||||
assert(class__is_struct(new_structure));
|
||||
|
||||
class__find_holes(structure, cu);
|
||||
class__find_holes(new_structure, new_cu);
|
||||
diff = class__size(structure) != class__size(new_structure) ||
|
||||
class__nr_members(structure) != class__nr_members(new_structure) ||
|
||||
check_print_members_changes(structure, cu,
|
||||
|
|
19
dwarves.c
19
dwarves.c
|
@ -414,9 +414,19 @@ size_t enumeration__fprintf(const struct tag *tag_self,
|
|||
conf->suffix ? " " : "", conf->suffix ?: "");
|
||||
}
|
||||
|
||||
static void cu__find_class_holes(struct cu *self)
|
||||
{
|
||||
uint16_t id;
|
||||
struct class *pos;
|
||||
|
||||
cu__for_each_struct(self, id, pos)
|
||||
class__find_holes(pos, self);
|
||||
}
|
||||
|
||||
void cus__add(struct cus *self, struct cu *cu)
|
||||
{
|
||||
list_add_tail(&cu->node, &self->cus);
|
||||
cu__find_class_holes(cu);
|
||||
}
|
||||
|
||||
static void ptr_table__init(struct ptr_table *self)
|
||||
|
@ -1150,12 +1160,9 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu,
|
|||
type->tag == DW_TAG_class_type ? "class" : "struct",
|
||||
conf->type_spacing - 7,
|
||||
type__name(ctype), name);
|
||||
else {
|
||||
struct class *class = tag__class(type);
|
||||
|
||||
class__find_holes(class, cu);
|
||||
printed += class__fprintf(class, cu, &tconf, fp);
|
||||
}
|
||||
else
|
||||
printed += class__fprintf(tag__class(type),
|
||||
cu, &tconf, fp);
|
||||
break;
|
||||
case DW_TAG_union_type:
|
||||
ctype = tag__type(type);
|
||||
|
|
15
dwarves.h
15
dwarves.h
|
@ -50,6 +50,21 @@ struct ptr_table {
|
|||
continue; \
|
||||
else
|
||||
|
||||
/**
|
||||
* cu__for_each_struct - iterate thru all the struct tags
|
||||
* @cu: struct cu instance to iterate
|
||||
* @pos: struct class iterator
|
||||
* @id: uint16_t tag id
|
||||
*/
|
||||
#define cu__for_each_struct(cu, id, pos) \
|
||||
for (id = 0, pos = tag__class(cu->types_table.entries[id]); \
|
||||
id < cu->types_table.nr_entries; \
|
||||
pos = tag__class(cu->types_table.entries[++id])) \
|
||||
if (pos == NULL || \
|
||||
!tag__is_struct(class__tag(pos))) \
|
||||
continue; \
|
||||
else
|
||||
|
||||
/**
|
||||
* cu__for_each_function - iterate thru all the function tags
|
||||
* @cu: struct cu instance to iterate
|
||||
|
|
|
@ -306,9 +306,6 @@ void type__emit(struct tag *tag_self, struct cu *cu,
|
|||
{
|
||||
struct type *ctype = tag__type(tag_self);
|
||||
|
||||
if (tag__is_struct(tag_self))
|
||||
class__find_holes(tag__class(tag_self), cu);
|
||||
|
||||
if (type__name(ctype) != NULL ||
|
||||
suffix != NULL || prefix != NULL) {
|
||||
struct conf_fprintf conf = {
|
||||
|
|
2
pahole.c
2
pahole.c
|
@ -454,8 +454,6 @@ static struct tag *tag__filter(struct tag *tag, struct cu *cu,
|
|||
decl_exclude_prefix_len) == 0))
|
||||
return NULL;
|
||||
|
||||
class__find_holes(class, cu);
|
||||
|
||||
if (class->nr_holes < nr_holes ||
|
||||
class->nr_bit_holes < nr_bit_holes ||
|
||||
(hole_size_ge != 0 && !class__has_hole_ge(class, hole_size_ge)))
|
||||
|
|
|
@ -20,9 +20,6 @@ static struct conf_fprintf conf = {
|
|||
|
||||
static void emit_tag(struct tag *self, uint32_t tag_id, struct cu *cu)
|
||||
{
|
||||
if (tag__is_struct(self))
|
||||
class__find_holes(tag__class(self), cu);
|
||||
|
||||
conf.no_semicolon = tag__is_function(self);
|
||||
|
||||
printf("%d ", tag_id);
|
||||
|
|
|
@ -118,9 +118,7 @@ static int refcnt_function_iterator(struct function *function,
|
|||
|
||||
static int refcnt_tag_iterator(struct tag *tag, struct cu *cu, void *cookie)
|
||||
{
|
||||
if (tag__is_struct(tag))
|
||||
class__find_holes(tag__class(tag), cu);
|
||||
else if (tag__is_function(tag))
|
||||
if (tag__is_function(tag))
|
||||
refcnt_function_iterator(tag__function(tag), cu, cookie);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue