[PATCH] D129634: [X86] Fix updating LiveVariables in convertToThreeAddress
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 05:22:14 PDT 2022
foad created this revision.
Herald added subscribers: jsji, mstorsjo, pengfei, hiraditya.
Herald added a project: All.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fix all instances of:
- Bad machine code: Kill missing from LiveVariables ***
in the X86 CodeGen tests with D129213 <https://reviews.llvm.org/D129213> applied, which adds verification
of LiveIntervals after the TwoAddressInstruction pass runs.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129634
Files:
llvm/lib/Target/X86/X86InstrInfo.cpp
Index: llvm/lib/Target/X86/X86InstrInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.cpp
+++ 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129634.444231.patch
Type: text/x-patch
Size: 2826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220713/d5db0239/attachment.bin>
More information about the llvm-commits
mailing list