Teach X86FloatingPoint that a register can be killed multiple times by the same

instruction.

This instruction would crash the pass:

  INLINEASM <es:foo $0 $1>, 9, %FP0<kill>, 9, %FP0<kill>, 14, %EFLAGS<earlyclobber,def,dead>

Now it doesn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2010-04-28 18:28:37 +00:00
parent 598f4abdf4
commit 7261fb2a6f

View File

@@ -1088,8 +1088,7 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) {
// 'f' constraint. These should be turned into the current ST(x) register // 'f' constraint. These should be turned into the current ST(x) register
// in the machine instr. Also, any kills should be explicitly popped after // in the machine instr. Also, any kills should be explicitly popped after
// the inline asm. // the inline asm.
unsigned Kills[7]; unsigned Kills = 0;
unsigned NumKills = 0;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
MachineOperand &Op = MI->getOperand(i); MachineOperand &Op = MI->getOperand(i);
if (!Op.isReg() || Op.getReg() < X86::FP0 || Op.getReg() > X86::FP6) if (!Op.isReg() || Op.getReg() < X86::FP0 || Op.getReg() > X86::FP6)
@@ -1103,7 +1102,7 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) {
// asm. We just remember it for now, and pop them all off at the end in // asm. We just remember it for now, and pop them all off at the end in
// a batch. // a batch.
if (Op.isKill()) if (Op.isKill())
Kills[NumKills++] = FPReg; Kills |= 1U << FPReg;
} }
// If this asm kills any FP registers (is the last use of them) we must // If this asm kills any FP registers (is the last use of them) we must
@@ -1114,9 +1113,11 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) {
// Note: this might be a non-optimal pop sequence. We might be able to do // Note: this might be a non-optimal pop sequence. We might be able to do
// better by trying to pop in stack order or something. // better by trying to pop in stack order or something.
MachineBasicBlock::iterator InsertPt = MI; MachineBasicBlock::iterator InsertPt = MI;
while (NumKills) while (Kills) {
freeStackSlotAfter(InsertPt, Kills[--NumKills]); unsigned FPReg = CountTrailingZeros_32(Kills);
freeStackSlotAfter(InsertPt, FPReg);
Kills &= ~(1U << FPReg);
}
// Don't delete the inline asm! // Don't delete the inline asm!
return; return;
} }