This patch does some cleanup to ensure that a clang stage2 build succeeds when using only DBG_INSTR_REF variable locations (plus the exceptions noted in the previous patch). There are still passes that will need updating, however most variable locations now survive most passes.
The most significant change is in LiveDebugVariables: because there are no DBG_VALUEs referring to virtual registers (which is now asserted), we can get away with just unlinking debug instructions from blocks, then linking them back in after regalloc finishes. This avoids the interval splitting and other operations. Debug instructions are stored with their slot and block, then re-inserted in the order they were removed.
Other passes need a tweak or two to correctly identify debug instructions now that DBG_PHIs can be generated during SelectionDAG.
Parameter variable locations are emitted by directly constructing a DBG_VALUE to be inserted later during SelectionDAGBuilder; I've added a helper lambda there to emit a DBG_INSTR_REF when we're using instruction referencing.
X86InstrInfo.cpp needs to un-set an instruction number: X86 usually creates subtract instructions instead of CMPs, then mutates them to be CMPs later on if no-one uses the result. That causes any debug users referring to the subs register def to now refer to a register use; which is an erronous behaviour.
Finally, I've deleted a bunch of DBG_VALUE %vreg's from the tests for other instruction referencing behaviour: they shouldn't be generated by SelectionDAG now, and shouldn't be in test cases for instruction referencing. None of them affect the tested behaviours, those all involve DBG_INSTR_REFs.
nit: maybe it's just me but "insert in front of it" feels a bit ambiguous in this scenario, perhaps "insert before it" is clearer?