How does Debugify detect debug value bugs? (original) (raw)
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?
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
poisonvalue). - 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!
Hi. There are two “modes” of debugify pass(es) - synthetic that operate with artificial metadata being generated, and original mode that verifies preserving of original/-g generated debug info. So, in the original mode, there is a way to detect dropping of debug values (and it is being ported to new debug records mechanism). E.g. you may take a look into ⚙ D115623 [Debugify] Use DebugifyLevel in Debugify original mode.