The function MachineInstr::copyImplicitOps(MachineFunction &MF, const MachineInstr &MI) and MachineInstrBuilder::copyImplicitOps(const MachineInstr &OtherMI) will copy all implicit ops from Src_MI to Dst_MI.
When the Src_MI and Dst_MI has the same implicit ops, if we still call copyImplicitOps(), we will get some redundant implicit reg.
For example:
The Src_MI is:
BLR implicit $lr, implicit $rm, implicit killed $r3
The Dst_MI is:
BCLR $cr5lt, implicit $lr, implicit $rm
After calling Dst_MI.copyImplicitOps(Src_MI), we will get:
BCLR $cr5lt, implicit $lr, implicit $rm, implicit $lr, implicit $rm, implicit killed $r3
On the some targets like PowerPC, it's obvious that the second implicit $lr, implicit $rm is redundant, should be removed.
The right result should be:
BCLR $cr5lt, implicit $lr, implicit $rm, implicit killed $r3
The function copyImplicitOps() should skip those implicit operands which both Src_MI and Dst_MI have.
This patch is to add a new parameter SkipDuplicated for copyImplicitOps(), so we can choose whether we need skip those duplicated operands.
clang-format: please reformat the code