[Not for review or submission yet, aim is to evaluate this first]
This patch hopefully alleviates some of the regressions seen with D56151 / PR40010, where unfortunate DBG_VALUE creation by SelectionDAG generates debug uses of dead VRegs, that then get dropped later. More information on what's going on is in PR41583: this patch causes SelectionDAG to point/place DBG_VALUEs at the VReg/instruction where an exported Value is written to its long-term VReg, rather than where the Value is computed.
This isn't a panacea: fractionally more variable locations get dropped in a clang-3.4 build, largely because of long-term VRegs subsequently being optimised out by OptimizePHIs and similar passes. In effect this change would swap (assuming D56151 is applied) locations dropped due to liveness issues, for locations dropped due to long-term VRegs being optimised out. (For me, the latter is more preferable).
There's the possibility that this won't resolve the regressions seen with D56151 if the problem really hinges on register class copies: I haven't managed to replicate such a scenario on X86 or AArch64 as they have simple register hierarchies. The problem would be analogous (differences between value-computed and value-used VRegs and locations) but would be more unpleasent to solve.