SelectionDAG::transferDbgValues() can 'reattach' SDDbgValue from one to another node, but doesn't change its source order. If the destination node has the order greater than the SDDbgValue, there are two possible issues revealed later:
- If debug info is attached to an instruction that is the first definition of a register, this ends up with a def-after-use case and the debug info gets 'undef' later.
- If MIR has another definition of a register above the debug info, debug info won't be 'undef' but may represent a source variable incorrectly because it appears (significantly) before an instruction corresponded to this debug info.
So, the patch changes the order of an SDDbgValue if it's being moved to a node with greater order.
Do we need all three dbg.values or could we further reduce the testcase by removing all but one?