Bug: https://bugs.llvm.org/show_bug.cgi?id=41992
This patch prevents DBG_VALUE instructions being incorrectly coalesced by
liveDebugVariables.
A 'UserValue' roughly represents a source variable. A UserValue was identified
by looking at the source variable, DIExpression, and the inlined-at location
of the source variable.
This is a problem because this means arbitrary DIExpressions were being used
to classify the UserValues. For example, a DW_OP_deref on the value presented
in the DBG_VALUE doesn't change what source variable we're describing. Instead
we should only be looking at the fragment info in the DIExpression.
This patch identifies UserValues by looking at the source vaiable, the variable
fragment info, and the inlined-at location. UserValue no longer tracks the
DIExpression associated with the set of DBG_VALUES.
DbgValueLocation seemed like a good place to keep track of the DIExpression
used by the DBG_VALUE because:
- This stops the locations with different DIExpressions being coalesced by the interval map used to track the uses.
- There is a 1-to-1 mapping of use locations to DIExpressions.
- Minimal source changes required to implement this fix.
I've added a test which covers the case outlined in the bug.