Currently, an error exists when InstrRefBasedLDV observes transfers of variables across copies, which causes it to lose track of variables under certain circumstances, resulting in shorter lifetimes for those variables as LDV gives up searching for live locations for them.
The issue can be summarised as, when the TransferTracker observes a copy, under certain circumstances it may start tracking variables, that previously were in the source location, in the destination location instead. This is obviously valid, but it then tries to clobber the destination location due to it being overwritten, including clobbering the variables that were just moved to use this location. This does not immediately kill the variable, but causes it to stop being tracked, potentially ending its lifetime early.
This patch fixes this issue by first tracking the specific set of variables and values that already live in the destination, then after updating our underlying store of values (in the MLocTracker) we try to find new locations for all those variables that have been clobbered. Only after that do we potentially move other variables into the destination location, ensuring that no variables are erroneously clobbered and all the existing variables in the destination are given proper homes.
Is it significant that the "The copy might have clobbered variables based on the destination register" loop has moved above up above this part?