For some targets, a copy can use a register multiple times, e.g. ppc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88895 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/ProcessImplicitDefs.cpp b/lib/CodeGen/ProcessImplicitDefs.cpp
index 23b78c7..455964b 100644
--- a/lib/CodeGen/ProcessImplicitDefs.cpp
+++ b/lib/CodeGen/ProcessImplicitDefs.cpp
@@ -77,6 +77,7 @@
SmallVector<MachineInstr*, 8> ImpDefMIs;
MachineBasicBlock *Entry = fn.begin();
SmallPtrSet<MachineBasicBlock*,16> Visited;
+ SmallPtrSet<MachineInstr*, 8> ModInsts;
for (df_ext_iterator<MachineBasicBlock*, SmallPtrSet<MachineBasicBlock*,16> >
DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited);
@@ -201,6 +202,8 @@
MachineOperand &RMO = UI.getOperand();
MachineInstr *RMI = &*UI;
++UI;
+ if (ModInsts.count(RMI))
+ continue;
MachineBasicBlock *RMBB = RMI->getParent();
if (RMBB == MBB)
continue;
@@ -216,6 +219,7 @@
RMI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF));
for (int j = RMI->getNumOperands() - 1, ee = 0; j > ee; --j)
RMI->RemoveOperand(j);
+ ModInsts.insert(RMI);
continue;
}
@@ -226,6 +230,7 @@
RMO.setIsKill();
}
}
+ ModInsts.clear();
ImpDefRegs.clear();
ImpDefMIs.clear();
}