[DebugInfo][InstrRef] Terminate overlapping variable fragments
authorJeremy Morse <jeremy.morse@sony.com>
Mon, 29 Nov 2021 23:09:05 +0000 (23:09 +0000)
committerJeremy Morse <jeremy.morse@sony.com>
Mon, 29 Nov 2021 23:37:20 +0000 (23:37 +0000)
commit0eee844539e406dfa8010a129ea3655d2298ac10
tree51cc6c5d21a24b00b01a9909448355ff88c3e045
parent45ecfed6c636d06f76bca0a44803e945cdae9506
[DebugInfo][InstrRef] Terminate overlapping variable fragments

If we have a variable where its fragments are split into overlapping
segments:

    DBG_VALUE $ax, $noreg, !123, !DIExpression(DW_OP_LLVM_fragment_0, 16)
    ...
    DBG_VALUE $eax, $noreg, !123, !DIExpression(DW_OP_LLVM_fragment_0, 32)

we should only propagate the most recently assigned fragment out of a
block. LiveDebugValues only deals with live-in variable locations, as
overlaps within blocks is DbgEntityHistoryCalculators domain.

InstrRefBasedLDV has kept the accumulateFragmentMap method from
VarLocBasedLDV, we just need it to recognise DBG_INSTR_REFs. Once it's
produced a mapping of variable / fragments to the overlapped variable /
fragments, VLocTracker uses it to identify when a debug instruction needs
to terminate the other parts it overlaps with. The test is updated for
some standard "InstrRef picks different registers" variation, and the
order of some unrelated DBG_VALUEs changes.

Differential Revision: https://reviews.llvm.org/D114603
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
llvm/test/DebugInfo/MIR/X86/live-debug-values-fragments.mir
llvm/unittests/CodeGen/InstrRefLDVTest.cpp