For the following mir case below:
%2:gr32 = MOV32ri -343593632
$edx = COPY %2:gr32
TCRETURNdi64 @llvm_gcda_emit_function, 0
$edx = COPY %2:gr32
TCRETURNdi64 @llvm_gcda_emit_function, 0
...
During RegisterCoalescing, %edx = COPY %2:gr32 will be replaced by %edx = MOV32ri -343593632 in reMaterializeTrivialDef, and each time we do the replacement, shrinkUses will be called to shrink the live range of %2. shrinkUses is a relative high cost operation. If we have a lot of COPY to be eliminated in reMaterializeTrivialDef, we will see compile time problem. However, if we know there is other use of %2 after the current COPY instruction, we don't need to call shrinkUses because we know the live range of %2 is not going to change after the COPY is removed.
The patch will skip shrinkUses call when deleting a COPY instruction if the live range of %2 lives at the DeadSlot of the COPY instruction and the live range doesn't live at the end of current basicblock (to avoid the current COPY is the last use of %2 in a loop or cycle)
We saw in an extreme case that the file's compile time was reduced from 300s to 200s because of the patch.