This is an archive of the discontinued LLVM Phabricator instance.

WIP: [DWARF] Collect statistics for DW_OP_entry_value
AbandonedPublic

Authored by vsk on Jul 23 2019, 5:27 PM.

Details

Reviewers
None
Summary

It might be interesting to see how many parameters with entry_value locations there are compared to how many parameters-with-location there are overall.

I can clean up this patch and push it forward if there's general interest. Here are some numbers from a stage2 RelAsserts build of clang.

~/src/builds/llvm-project-master-stage2-RA (0) $ ../llvm-project-master-RA/bin/llvm-dwarfdump --statistics ./bin/clang.dSYM | ppjson
{ 'call site entries': 6113835,
  'file':  'bin/clang.dSYM/Contents/Resources/DWARF/clang',
  'formal params with binary location': 5928235,
  'formal params with binary location containing entry value': 0,
  'formal params with source location': 4200769,
  'formal params with type': 8436986,
  'format':  'Mach-O 64-bit x86-64',
  'inlined funcs with abstract origins': 5859344,
  'inlined functions': 5859344,
  'scope bytes covered': 563026378,
  'scope bytes total': 969630990,
  'source functions': 468524,
  'source functions with location': 468075,
  'source variables': 10246465,
  'total formal params': 8436986,
  'total function size': 65502932,
  'total inlined function size': 48065586,
  'total vars': 1142370,
  'unique source variables': 1408162,
  'variables with location': 6751342,
  'vars with binary location': 710703,
  'vars with source location': 1059166,
  'vars with type': 1142370,
  'version': 3}

(with -femit-debug-entry-values)
~/src/builds/param-entry-vals-stage2 (0) $ ../llvm-project-master-RA/bin/llvm-dwarfdump --statistics ./bin/clang.dSYM | ppjson
{ 'call site entries': 6471968,
  'file':  'bin/clang.dSYM/Contents/Resources/DWARF/clang',
  'formal params with binary location': 5928218,
  'formal params with binary location containing entry value': 70017,
  'formal params with source location': 4200754,
  'formal params with type': 8437413,
  'format':  'Mach-O 64-bit x86-64',
  'inlined funcs with abstract origins': 5859331,
  'inlined functions': 5859331,
  'scope bytes covered': 580573865,
  'scope bytes total': 969629704,
  'source functions': 468520,
  'source functions with location': 468071,
  'source variables': 10246437,
  'total formal params': 8437413,
  'total function size': 65502621,
  'total inlined function size': 48065442,
  'total vars': 1142364,
  'unique source variables': 1408152,
  'variables with location': 6751217,
  'vars with binary location': 710704,
  'vars with source location': 1059160,
  'vars with type': 1142364,
  'version': 3}

Diff Detail

Event Timeline

vsk created this revision.Jul 23 2019, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2019, 5:27 PM

@vsk Thanks for this! We have discussed about this on the other threads and the stats is useful for sure!
Having this stats gives us info about the "normal" (non-entry values) debug location coverage, because those locations with the entry value are useless if do not have proper call_site and call_site_paramters debug information generated in the .debug_info section.

WDYT about having a separate tool that will calculate and report more (verbose) info about the debug location coverage? I have already mentioned it on the D58042 and the link of the 'WIP' of the tool is https://github.com/djolertrk/llvm-locstats.
We can play with that and add more options we found useful for us.

vsk abandoned this revision.Jul 24 2019, 8:26 AM

@vsk Thanks for this! We have discussed about this on the other threads and the stats is useful for sure!
Having this stats gives us info about the "normal" (non-entry values) debug location coverage, because those locations with the entry value are useless if do not have proper call_site and call_site_paramters debug information generated in the .debug_info section.

WDYT about having a separate tool that will calculate and report more (verbose) info about the debug location coverage? I have already mentioned it on the D58042 and the link of the 'WIP' of the tool is https://github.com/djolertrk/llvm-locstats.
We can play with that and add more options we found useful for us.

Thanks for the link. I’ll set this patch aside for now. Maybe any relevant parts can be folded into the locstats tool later.

Copying some discussion with Eric about the goals of this:

On Jul 23, 2019, at 9:31 PM, Eric Christopher wrote:

I guess? I'm curious what we'd get out of it in general? Is the
thought that we could try to classify how often we have to do more
work to recover parameters? Not against it, just trying to see why :)

Vedant:
I’d like to get the percentage of parameters guaranteed to have an available location.

I think this should correlate with backtrace quality (if not, that’s interesting too, maybe it means the debugger has bugs).

Counting entry_value descriptions is a starting point, but I think you’d need to check that the ranges in a parameter location description span the whole function to finish the patch.

As-is, I thought “# entry values” could be fun to look at as the callsiteparam work lands.

@vsk IIUC, you think the tool will be useful ? :)

I’ll set this patch aside for now.

I think the goal of this patch is desirable for sure. In addition, I am not opposed to coexisting of this kind of stats within both of the llvm-dwarfdump and llvm-locstats, but that can be a point of discussion.

Maybe any relevant parts can be folded into the locstats tool later.

Thanks! Those parts can be folded for sure! Just to mention, currently, there is an option in the llvm-locstats tool (--ignore-entry-values) that reports the debug location coverage by ignoring the debug entry values.

vsk added a comment.Jul 25 2019, 10:24 AM

@vsk IIUC, you think the tool will be useful ? :)

I’ll set this patch aside for now.

I think the goal of this patch is desirable for sure. In addition, I am not opposed to coexisting of this kind of stats within both of the llvm-dwarfdump and llvm-locstats, but that can be a point of discussion.

Maybe any relevant parts can be folded into the locstats tool later.

Thanks! Those parts can be folded for sure! Just to mention, currently, there is an option in the llvm-locstats tool (--ignore-entry-values) that reports the debug location coverage by ignoring the debug entry values.

Thanks, that's perfect. I was looking for something just like 'llvm-locstats -only-formal-parameters [-ignore-entry-values]'. I'd love to see this functionality upstream eventually (maybe as a dwarfdump subtool?).

@vsk Thanks! As soon as we re-land the callsiteparam work I will start cleaning up the code and up streaming it!

There are options to look only for parameters or local variables. The help output:

llvm-locstats --help
...

Specific Options:

 --ignore-entry-values    - Ignore the location statistics on locations with entry values.
 --ignore-inlined         - Ignore the location statistics on inlined instances.
 --only-formal-parameters - Calculate the location statistics only for formal parameters.
 --only-variables         - Calculate the location statistics only for local variables.

...