The problem of "false positive results" in Debugify reports was discussed at one of the LLVM Dev meetings. This RFC aims at solving this problem for reports about lost Debug Locations (instruction source locations).
Discourse discussion: https://discourse.llvm.org/t/debugify-false-positives-elimination/69614
There are several scenarios where debug locations are dropped, but should not be reported by Debugify as losses:
- instruction's DebugLoc should be dropped if it cannot be unambiguously determined (according to How-to-update-debug-info document)
- instruction's DebugLoc is copied from an other instruction (loss should not be reported for both instructions)
In my opinion, those cases should not be treated as losses, since DebugLocs are explicitly updated, but couldn't be reconstructed.
My proposal, in this patch, is to add a flag to the Instruction (droppedLocation), which should be set if the DebugLoc is explicitly set to empty for that instruction. Then, during Debugify analysis, we should not report DebugLoc loss if instruction's DebugLoc is explicitly updated (by checking the flag).
Proposed solution was tested by compiling clang-14 with -fverify-debuginfo-preserve. The results show around 65% of reported DebugLoc losses is eliminated.