llvm.org GIT mirror llvm / c674a92
Don't assume that only Uses can be kills. Defs are marked as kills initially when there are no uses. This fixes a dangling-pointer bug, where pointers to deleted instructions were not removed from kills lists. More info here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-July/009749.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40131 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 13 years ago
3 changed file(s) with 10 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
228228 bool Removed = false;
229229 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
230230 MachineOperand &MO = MI->getOperand(i);
231 if (MO.isReg() && MO.isUse() && MO.getReg() == reg) {
231 if (MO.isReg() && MO.isKill() && MO.getReg() == reg) {
232232 MO.unsetIsKill();
233233 Removed = true;
234234 break;
581581 if (VI.DefInst == OldMI)
582582 VI.DefInst = NewMI;
583583 }
584 if (MO.isUse()) {
585 if (MO.isKill()) {
586 MO.unsetIsKill();
587 addVirtualRegisterKilled(Reg, NewMI);
588 }
589 // If this is a kill of the value, update the VI kills list.
590 if (VI.removeKill(OldMI))
591 VI.Kills.push_back(NewMI); // Yes, there was a kill of it
592 }
584 if (MO.isKill()) {
585 MO.unsetIsKill();
586 addVirtualRegisterKilled(Reg, NewMI);
587 }
588 // If this is a kill of the value, update the VI kills list.
589 if (VI.removeKill(OldMI))
590 VI.Kills.push_back(NewMI); // Yes, there was a kill of it
593591 }
594592 }
595593 }
954954 void SimpleRegisterCoalescing::unsetRegisterKill(MachineInstr *MI, unsigned Reg) {
955955 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
956956 MachineOperand &MO = MI->getOperand(i);
957 if (MO.isReg() && MO.isUse() && MO.isKill() && MO.getReg() &&
957 if (MO.isReg() && MO.isKill() && MO.getReg() &&
958958 mri_->regsOverlap(rep(MO.getReg()), Reg))
959959 MO.unsetIsKill();
960960 }
978978
979979 for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) {
980980 MachineOperand &MO = MI->getOperand(i);
981 if (MO.isReg() && MO.isUse() && MO.isKill() && MO.getReg() &&
981 if (MO.isReg() && MO.isKill() && MO.getReg() &&
982982 mri_->regsOverlap(rep(MO.getReg()), Reg)) {
983983 MO.unsetIsKill();
984984 }