[PATCH] D69027: [llvm-dwarfdump][Statistics] Fix calculation of OffsetToFirstDefinition

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 16:46:09 PST 2019


dblaikie added a comment.

In D69027#1739944 <https://reviews.llvm.org/D69027#1739944>, @krisb wrote:

> When I started to work on the statistics, I also thought that the percentage buckets are to show completeness of the debug info. Unfortunately, due to BB reordering this information, sometimes not just imprecise, but rather terribly wrong. And in general case, we can't even guarantee any precision. I agree with @dblaikie; we need a way to calculate adjusted scope correctly regardless of basic block reordering to justify the notion of the adjusted scope itself. Otherwise, I'd prefer to reduce maintenance costs and to calculate debug info coverage against the full enclosing scope. In such a case, only changes in percentages would make sense, but at least this information won't be misleading. So, I tend to abandon this patch and proceed with another one that changes all the calculations against an adjusted scope to calculations against a full enclosing scope (if there are no strong objections).
>
> There is another thought about the adjusted scope, though. It's clearly out of the scope of this patch, but it's probably worth to discuss it here. I just found that the dwarf specification (both v4 and v5) provides the `DW_AT_start_scope` attribute, which represents exactly the 'adjusted' scope. So, as a possible solution we can move all the calculations of the adjusted scope to the compiler (but I have no idea if the compiler can emit something precise enough here and it's worth to do for statistic's purpose). The usage of the attribute was discussed in the context of the `dwarflint --stats` tool, but it was more than nine years ago: https://lists.fedorahosted.org/pipermail/elfutils-devel/2010-July/001498.html. As I can see, neither gcc nor clang produces this attribute at the moment.


Yeah, that could be handy - but probably pretty complicated to propagate through the compiler & only have limited benefits to users (in normal debugger scenarios, rather than stats) - the difference between "this variable is out of scope" (or using another variable that would otherwise have been shadowed - that's pretty important) and "this variable's value is optimized out". The complexity of the implementation might be why it's not been implemented - possible that an implementation might be justifiable in a context of bigger improvements like is_stmt accuracy or sub-expression source range grouping, or other ideas that've been thrown around from time to time.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D69027





More information about the llvm-commits mailing list