diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -1249,6 +1249,8 @@ if (LV) { // Update live variables. LV->getVarInfo(InRegLEA).Kills.push_back(NewMI); + if (InRegLEA2) + LV->getVarInfo(InRegLEA2).Kills.push_back(NewMI); LV->getVarInfo(OutRegLEA).Kills.push_back(ExtMI); if (IsKill) LV->replaceKillInstruction(Src, MI, *InsMI); @@ -1337,6 +1339,7 @@ bool Is64Bit = Subtarget.is64Bit(); bool Is8BitOp = false; + unsigned NumRegOperands = 2; unsigned MIOpc = MI.getOpcode(); switch (MIOpc) { default: llvm_unreachable("Unreachable!"); @@ -1384,7 +1387,8 @@ if (ImplicitOp.getReg() != 0) MIB.add(ImplicitOp); NewMI = MIB; - + if (LV && SrcReg != Src.getReg()) + LV->getVarInfo(SrcReg).Kills.push_back(NewMI); break; } case X86::SHL8ri: @@ -1416,6 +1420,8 @@ MIB.add(ImplicitOp); NewMI = addOffset(MIB, 1); + if (LV && SrcReg != Src.getReg()) + LV->getVarInfo(SrcReg).Kills.push_back(NewMI); break; } case X86::DEC64r: @@ -1437,7 +1443,8 @@ MIB.add(ImplicitOp); NewMI = addOffset(MIB, -1); - + if (LV && SrcReg != Src.getReg()) + LV->getVarInfo(SrcReg).Kills.push_back(NewMI); break; } case X86::DEC8r: @@ -1485,8 +1492,13 @@ MIB.add(ImplicitOp2); NewMI = addRegReg(MIB, SrcReg, isKill, SrcReg2, isKill2); - if (LV && Src2.isKill()) - LV->replaceKillInstruction(SrcReg2, MI, *NewMI); + if (LV) { + if (SrcReg2 != Src2.getReg()) + LV->getVarInfo(SrcReg2).Kills.push_back(NewMI); + if (SrcReg != SrcReg2 && SrcReg != Src.getReg()) + LV->getVarInfo(SrcReg).Kills.push_back(NewMI); + } + NumRegOperands = 3; break; } case X86::ADD8rr: @@ -1525,6 +1537,8 @@ MIB.add(ImplicitOp); NewMI = addOffset(MIB, MI.getOperand(2)); + if (LV && SrcReg != Src.getReg()) + LV->getVarInfo(SrcReg).Kills.push_back(NewMI); break; } case X86::ADD8ri: @@ -1729,6 +1743,7 @@ .add(MI.getOperand(2)) .add(Src) .add(MI.getOperand(3)); + NumRegOperands = 4; break; } } @@ -1736,10 +1751,11 @@ if (!NewMI) return nullptr; if (LV) { // Update live variables - if (Src.isKill()) - LV->replaceKillInstruction(Src.getReg(), MI, *NewMI); - if (Dest.isDead()) - LV->replaceKillInstruction(Dest.getReg(), MI, *NewMI); + for (unsigned I = 0; I < NumRegOperands; ++I) { + MachineOperand &Op = MI.getOperand(I); + if (Op.isDead() || Op.isKill()) + LV->replaceKillInstruction(Op.getReg(), MI, *NewMI); + } } MachineBasicBlock &MBB = *MI.getParent();