This stack of patches are the result of the discussion on D70121 and is split up
to (hopefully) make reviewing easier:
D74052 -- (Mostly) NFC: Prep work
<this> -- Functional change
D74055 -- NFC: Update DbgValueLocation class name and instance names to suit new semantics
D74057 -- NFC: Update UserValue methods to use FragmentInfo instead of DIExpression
These patches fix the issues shown in:
https://bugs.llvm.org/show_bug.cgi?id=41992
https://bugs.llvm.org/show_bug.cgi?id=43957
Functional change summary:
LDV uses interval maps to explicitly represent DBG_VALUE intervals. DBG_VALUEs
are filtered into an interval map based on their { Variable, DIExpression }. The
interval map will coalesce adjacent entries that use the same { Location }.
This causes incorrect debuginfo. Consider the following example:
DBG_VALUE %0, $noreg, "x", DIExpression() ; DV1 ... DBG_VALUE %1, $noreg, "x", DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value) ; DV2 ... DBG_VALUE %0, $noreg, "x", DIExpression() ; DV3
DV2 is put into a separate interval map because it has a different
{ Variable, DIExpression } pair so we get:
Map A: [DV1, DV3):%0, [DV3, ...):%0 ** ranges because they use the same { Location }. [DV1, ...):%0 Map B: [DV2, ...):%1+4
When the maps are used to emit DBG_VALUEs again we get:
DBG_VALUE %0, $noreg, "x", DIExpression() ; DV1 ... DBG_VALUE %1, $noreg, "x", DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value) ; DV2
This patch fixes the problem by using { Variable, Fragment } to filter the
DBG_VALUEs into maps, and coalesces adjacent entries iff they have the same
{ Location, DIExpression } pair.
The solution is not perfect because we see the similar issues appear when
partially overlapping fragments are encountered, but is far simpler than a
complete solution (i.e. D70121).
This should be const. I'll fix this when I address reviewer comments.