When sinking instructions, and sinking DBG_VALUEs at the same time, we leave one DBG_VALUE at the source location to either mark an undef location, or copy-propagate it if it can be recovered. However, this remaining DBG_VALUE wasn't receiving any further copy propagation (there can be multiple copies in a row), potentially leading to a debug use-before-def. Fix this by trying to copy-propagate all DBG_VALUEs, including those that used to refer to a sunk instruction,
While we're at it, "PerformTrivialForwardCoalescing" occasionally eliminates COPYs, leading to dropped variable locations in one of the added tests. Fix this by updating our list of debug-users-of-vregs whenever we coalesce a register this way.
There are zero changes to the location statistics for a clang-3.4 build with this patch (alas), it's purely a correctness thing.
You may notice that MachineSink.cpp seems to be accumulating a lot of debug related stuff... this is partially because it's had my attention through its use of collectDebugValues, but I would also describe shuffling DBG_VALUEs around as "fiddly". I'll see at some point whether this can be generalised in some way.
if (!AlreadySinking) ?