[patch] dwarf2out: Use DW_FORM_ref_udata (.debug -= 7.53%)

Jakub Jelinek jakub@redhat.com
Fri Oct 21 19:39:00 GMT 2011

On Fri, Oct 21, 2011 at 08:01:29PM +0200, Jan Kratochvil wrote:
> I had a draft patch to use DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref_udata and
> DW_FORM_ref4 which should be slightly smaller than just DW_FORM_ref_udata.
> But it produced larger files than just DW_FORM_ref_udata.  Assuming it was due
> to multiplied abbrev definitions.  One would need to decide when if it is
> worth to create a new smaller-sized abbrev but that seems too complicated for
> such kind of optimization.  There exist other project(s) in development for
> DWARF optimizations as a post-processing tool, this patch is meant just as
> a very simple way to reduce the (possibly intermediate) DWARF files.

Well, you calculate the sizes multiple times anyway, so I don't see why you
during the size calculations you couldn't start with DW_FORM_ref_udata
as first guess and compute on the side also total sizes of those
DW_FORM_ref_udata bytes and use that number plus the guessed length
of the whole CU to decide if replacing all DW_FORM_ref_udata with
DW_FORM_ref{1,2,4} wouldn't be beneficial.  Small complication for that is
that when there are multiple .debug_info/.debug_types sections that share
the same .debug_abbrev, the decision needs to be done for all of them

BTW, is your 

> +  /* The DIE sizes can increase, due to DW_FORM_ref_udata size increase
> +     dependent on increases of other DIE_OFFSETs.  */
> +  do
> +    {
> +      /* Initialize the beginning DIE offset - and calculate sizes/offsets.  */
> +      next_die_offset = init_die_offset;
> +      calc_die_sizes_change = false;
> +      calc_die_sizes (die);
> +    }
> +  while (calc_die_sizes_change);

loop guaranteed to terminate?  If the CU is either only growing or only
shrinking then it hopefully should, but it would be nice to assert that.
For references to DIEs with lower offsets you start with a roughly correct
guess, for references to DIEs with higher offsets you start with 0 and then
just keep growing?


More information about the Gcc-patches mailing list