[PATCH] D70548: [llvm-dwarfdump][Statistics] Unify coverage statistic computation

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 24 10:10:30 PST 2019


krisb added a comment.

In D70548#1757299 <https://reviews.llvm.org/D70548#1757299>, @dblaikie wrote:

> In D70548#1756279 <https://reviews.llvm.org/D70548#1756279>, @djtodoro wrote:
>
> > @krisb Thanks for working on this!
> >
> > Let me summarize this quickly.
> >
> > This will remove mixing between calculation against enclosing and adjusted scope. We have concluded the adjustment heuristics are confusing and wrong in many cases, so we are giving up on that. The alternative is to generate the `DW_AT_start_scope` attribute, that represents exactly the adjusted scope, and having that we will be able to calculate the debug location statistics for the pieces of code where the variable is alive.
> >
> > WDYT how "easy" will be to implement the `DW_AT_start_scope` attribute? I know that it might not be used anywhere else, but I think that having location statistics against variable's life will be very useful thing.
>
>
> See my reply from D69027 <https://reviews.llvm.org/D69027> - though thinking more closely, I'm not sure start_scope would really answer the question as it seems like it has many of the same issues as the adjusted scope we're removing - it assumes the code is laid out in order. Any use of DW_AT_ranges would invalidate it (& I /think/ many & perhaps most scopes are fragmented into ranges in optimized code which is where any of these stats are interesting) & basic block reordering, etc, is sort of the nail in the coffin.


The spec looks a bit confusing here, but if I understand it correctly, it should be possible to represent 'adjusted' scope precisely in all the situations.
Regarding `DW_AT_start_scope` the spec (dwarfv5) says (3.9 Declarations with Reduced Scope) :

> Any debugging information entry for a declaration (including objects, subprograms, types and modules) whose scope has an address range that is a subset of the address range for the lexical scope most closely enclosing the declared entity may have a DW_AT_start_scope attribute to specify that reduced range of addresses.
>  There are two cases:
> 
> 1. If the address range for the scope of the entry includes all of addresses for the containing scope except for a contiguous sequence of bytes at the beginning of the address range for the containing scope, then the address is specified using a value of class constant. ...
> 2. Otherwise, the set of addresses for the scope of the entity is specified using a value of class rnglistsptr. This value indicates the beginning of a range list.

I understand this as 'If it's possible to represent a reduced scope as an offset to an enclosing lexical scope, it is actually the offset. But in cases when there are no ways to correctly use offset here, it is described in a ranges list, which represents the reduced scope itself'.  The latter should allow handling fragmented scopes, blocks reordering, ..., etc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70548/new/

https://reviews.llvm.org/D70548





More information about the llvm-commits mailing list