- // If there are no defs with uses, the instruction is dead.
- if (AllDefsDead) {
- // Clear out the operands to take the registers out of their
- // use chains.
- while (unsigned Num = MI->getNumOperands())
- MI->RemoveOperand(Num-1);
-
- // Delete the actual instruction.
- AnyChanges = true;
- MI->eraseFromParent();
- MIE = MBB->rend();
- // MII is now pointing to the next instruction to process,
- // so don't increment it.
- continue;
+ // Record the physreg defs.
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = MI->getOperand(i);
+ if (MO.isReg() && MO.isDef()) {
+ unsigned Reg = MO.getReg();
+ if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
+ // Check the subreg set, not the alias set, because a def
+ // of a super-register may still be partially live after
+ // this def.
+ for (MCSubRegIterator SR(Reg, TRI,/*IncludeSelf=*/true);
+ SR.isValid(); ++SR)
+ LivePhysRegs.reset(*SR);
+ }
+ } else if (MO.isRegMask()) {
+ // Register mask of preserved registers. All clobbers are dead.
+ LivePhysRegs.clearBitsNotInMask(MO.getRegMask());