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

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 04:06:55 PDT 2019


krisb created this revision.
krisb added reviewers: djtodoro, aprantl, vsk, dblaikie.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

While calculating a variable's scope OffsetToFirstDefinition is supposed
to be applied to the scope if a definition of the variable doesn't match
the beginning of the scope (this may happen if a variable is defined
in the middle of a function, for example).

But this also causes inaccuracies in debug info statistics especially in
optimized code.
This patch is a try to reduce the number of these inaccuracies by:

- applying the offset to local variable's scopes only as the scope of

the function argument is the whole function,

- applying the offset before calculating a variable's coverage bucket,

otherwise statistics look inconsistent,

- while calculating the offset taking into account the fact, that the

scope may be represented as a set of disconnected ranges. Currently the offset
is calculated as a distance between an address where the scope starts
(scope's LowPC) and an address were a variable is defind (variable's LowPC).
Consider this two cases:

1. Scope ranges [0x04,0x08), [0x0a,0x0e) Variable location [0x0a,0x0b)

Scope = (0x08 - 0x04) + (0x0e - 0x0a) = 8
OffsetToFirstDef = 0x0a - 0x04 = 6
If we adjust the scope by the offset, it will be 2 bytes instead of 4
as it should be.

1. Scope ranges [0x00,0x02), [0x0a,0x0e) Variable location [0x0a,0x0b)

Scope = (0x02 - 0x00) + (0x0e - 0x0a) = 6
OffsetToFirstDef = 0x0a - 0x00 = 10
The offset is greater than the scope itself, so this will be counted as an error
and the offsest will be set to 0.


Repository:
  rL LLVM

https://reviews.llvm.org/D69027

Files:
  test/tools/llvm-dwarfdump/X86/locstats.ll
  tools/llvm-dwarfdump/Statistics.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69027.225191.patch
Type: text/x-patch
Size: 10108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191016/ab67dc43/attachment.bin>


More information about the llvm-commits mailing list