This is the mail archive of the
mailing list for the GCC project.
Re: Getting rid of duplicate .debug_ranges
On Fri, 2012-01-20 at 14:31 -0800, Cary Coutant wrote:
> >> Is there a way to detect that basic blocks have the same range even
> >> though they have different block numbers? Or am I not looking/thinking
> >> about this issue correctly?
> I may be oversimplifying this, but it seems that
> gen_inlined_subroutine_die generates a DW_AT_ranges list, then calls
> decls_for_scope, which results in a call to gen_lexical_block_die,
> which generates another DW_AT_ranges list, but in both cases,
> BLOCK_FRAGMENT_CHAIN(stmt) points to the same list of block fragments.
> I'd think you could just keep a single-entry cache in
> add_high_low_attributes that remembers the last value of
> BLOCK_FRAGMENT_CHAIN(stmt) and the pointer returned from add_ranges
> (stmt) for that chain. If you get a match, just generate a
> DW_AT_ranges entry using the range list already generated.
That does seem slightly oversimplified since the BLOCK_FRAGMENT_CHAINs
will be pointers to different copies. Jakub came up with a patch in the
bug report http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51902 that marks
BLOCKs that have the same ranges as their BLOCKSUPERCONTEXT in
function.c, which knowledge you can then use in dwarf2out.c to detect
duplicates. The patch goes a bit further by also trying to detect tail
range overlaps. Which can also be shared, but is more work to detect
correctly (so my suggestion would be to leave that out and just go for
exact overlap as a first step). I added a quick and dirty debug_info
scanner that shows equal and (fully) shared ranges to the bug report to
see how much duplication/sharing is going on.