This patch alters the debug-info salvaging behaviour of MachineCSE, and adds a test for its behaviour (only one opaque test is currently sensitive to MachineCSEs DI salvaging).
In the loop in MachineCSE::PerformTrivialCopyPropagation (see patch), for an arbitrary input instruction, MachineCSE tries to copy-propagate vreg reading operands to expose more CSE opportunities. This is great -- but the current call to changeDebugValuesDefReg then unconditionally rewrites the DBG_VALUE users of the COPY that was propagated. This means that any COPY instruction whose result is the subject of CSE will have its DBG_VALUEs copy-propagated too, even if the COPY lives on, which is a bit overkill. I believe this propagation is only necessary if the COPY is to be deleted -- hence in this patch, the DBG_VALUE updating is moved to only occur if the COPY is deleted.
While we're here, alter changeDebugValuesDefReg to find DBG_VALUEs by enumerating vreg users, which catches DBG_VALUEs that don't immediately follow the COPY. MachineCSE is the only remaining user of this function (assuming D56265 makes it in).
I've added a test that stimulates both behaviours -- first where a COPY is deleted (and thus all DBG_VALUE users must update) and one where it doesn't.
A clang-3.4 build with this patch ticks up a fractional amount, and the covered scope bytes ticks down a fraction too. The ticking down is likely because vreg liveness interacting with DBG_VALUEs is still an open problem.
Can you leave an explanatory comment here that will prevent somebody coming in later and moving it back to old location?