This is a follow-up to D57510. This patch removes the code from
DebugHandlerBase::beginFunction() which changes the starting label for
the first non-overlapping register-described DBG_VALUEs of parameters
to the beginning of the function. That code does not consider what defines the
registers, which can result in the ranges for the debug values starting before
their defining instructions. The code also violates the DbgValueHistoryMap's
ranges, which I think can make it quite confusing when troubleshooting.
We currently do not emit debug values for constant values directly at the
start of the function, so this code is still useful for such values, but my
intention is to remove the code from beginFunction() completely when we
In D57510, PrologEpilogInserter was amended so that parameter
DBG_VALUEs are kept at the start of the entry block, even after emission of
prologue code. That was done to reduce the degradation of debug
completeness from this patch. PR40638 is another example, where the
lexical-scope trimming that LDV does results in instructions after the prologue
being left without locations. There might be other cases where the
DBG_VALUEs are pushed further down, for which the DebugHandlerBase code
may be helpful, but as it now quite often result in incorrect locations,
even after the prologue, it seems better to remove that code, and try to
work our way up with accurate locations.
In the long run we should maybe not aim to provide accurate locations
inside the prologue. Some single location descriptions, at least those
referring to stack values, generate inaccurate values inside the
epilogue, so we maybe should not aim to achieve accuracy for location
lists. However, it seems that we now emit line number programs that can
result in GDB and LLDB stopping inside the prologue when doing line
number stepping into functions. See PR40188 for more information.
A summary of some of the changed test cases is available in PR40188#c2.