Index: lib/CodeGen/VirtRegMap.cpp =================================================================== --- lib/CodeGen/VirtRegMap.cpp +++ lib/CodeGen/VirtRegMap.cpp @@ -441,10 +441,25 @@ if (MI->isIdentityCopy()) { ++NumIdCopies; DEBUG(dbgs() << "Deleting identity copy.\n"); - if (Indexes) - Indexes->removeMachineInstrFromMaps(*MI); - // It's safe to erase MI because MII has already been incremented. - MI->eraseFromParent(); + + // A COPY which has an implicit def of a super register must + // become an IMPLICIT_DEF of that register. + if (MI->getNumOperands() > 2) { + MachineOperand &MO = MI->getOperand(2); + if (MO.isDef() && MO.isImplicit()) { + MI->setDesc(TII->get(TargetOpcode::IMPLICIT_DEF)); + MI->RemoveOperand(0); + MI->RemoveOperand(0); + MI->getOperand(0).setImplicit(false); + assert (MI->getNumOperands() == 1 && "Not a single super reg implicit def?"); + } + } + else { + if (Indexes) + Indexes->removeMachineInstrFromMaps(*MI); + // It's safe to erase MI because MII has already been incremented. + MI->eraseFromParent(); + } } } }