How does Debugify detect debug value bugs?

The LLVM Debugify pass (-passes=debugify,debugify-check) is designed to detect debug location and value issues in LLVM optimization passes[1]. However, in the source code of Debugify pass, only mis-sized debug values are checked, although the comment says :

I wonder if there’s an existing approach that hasn’t been implemented yet, or if this is something for future work?


  1. https://llvm.org/docs/HowToUpdateDebugInfo.html#the-debugify-utility-pass ↩︎

I think it’s plausible that this just hasn’t been implemented yet.
@djtodoro may remember more details?

AFAICT, the MissingVars BitVector entry for a variable is initialized to true (line 750), and reset to false iff a correctly-sized debug value is seen for that variable (line 781), so that MissingVars contains only variables without debug values. Notably, this only detects variables that have no debug values - it won’t serve to detect:

  • Debug values that are unnecessarily killed (i.e. they exist but have a poison value).
  • Debug values that are not duplicated when they ought to be (e.g. if we clone a basic block but fail to copy contained debug values).
  • Incorrect debug values.

I don’t know if anyone is actively running this at the moment to detect debug value errors - I suspect that either the space of captured errors is too small to be useful, or there are false positives that limit its usefulness, but I’d need to investigate a little to confirm this!

1 Like