Re-write partial_die_info allocation in load_partial_dies
load_partial_dies has a "while (1)" loop to visit each die, and create
partial_die_info if needed in each iteration, like this,
part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
while (1)
{
if (foo1) continue;
if (foo2) continue;
read_partial_die (, , part_die, ,);
....
part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
};
the code was written in a way that spaces are allocated on necessary on
cu->comp_unit_obstack. I want to class-fy partial_die_info, but
partial_die_info ctor can't follow XOBNEW immediately, so this patch
rewrite this loop to:
while (1)
{
if (foo1) continue;
if (foo2) continue;
struct partial_die_info pdi;
read_partial_die (, , &pdi, ,);
part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info);
memcpy (part_die, &pdi, sizeof (pdi));
};
we create a local variable pdi, if we need it, call XOBNEW, and copy.
This also reduce one XOBNEW call. I measured the number of XOBNEW call in
load_partial_dies when gdb reads dwarf2read.o, without this patch, it is
18827, and with this patch, it is 18826.
gdb:
2018-026-26 Yao Qi <yao.qi@linaro.org>
* dwarf2read.c (load_partial_dies): Move the location of XOBNEW.