mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
Strip old implicit operands after foldMemoryOperand.
The TII.foldMemoryOperand hook preserves implicit operands from the original instruction. This is not what we want when those implicit operands refer to the register being spilled. Implicit operands referring to other registers are preserved. This fixes PR11347. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144247 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1017,14 +1017,18 @@ bool InlineSpiller::foldMemoryOperand(MachineBasicBlock::iterator MI,
|
||||
const SmallVectorImpl<unsigned> &Ops,
|
||||
MachineInstr *LoadMI) {
|
||||
bool WasCopy = MI->isCopy();
|
||||
unsigned ImpReg = 0;
|
||||
|
||||
// TargetInstrInfo::foldMemoryOperand only expects explicit, non-tied
|
||||
// operands.
|
||||
SmallVector<unsigned, 8> FoldOps;
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
unsigned Idx = Ops[i];
|
||||
MachineOperand &MO = MI->getOperand(Idx);
|
||||
if (MO.isImplicit())
|
||||
if (MO.isImplicit()) {
|
||||
ImpReg = MO.getReg();
|
||||
continue;
|
||||
}
|
||||
// FIXME: Teach targets to deal with subregs.
|
||||
if (MO.getSubReg())
|
||||
return false;
|
||||
@@ -1045,7 +1049,20 @@ bool InlineSpiller::foldMemoryOperand(MachineBasicBlock::iterator MI,
|
||||
if (!LoadMI)
|
||||
VRM.addSpillSlotUse(StackSlot, FoldMI);
|
||||
MI->eraseFromParent();
|
||||
DEBUG(dbgs() << "\tfolded: " << *FoldMI);
|
||||
|
||||
// TII.foldMemoryOperand may have left some implicit operands on the
|
||||
// instruction. Strip them.
|
||||
if (ImpReg)
|
||||
for (unsigned i = FoldMI->getNumOperands(); i; --i) {
|
||||
MachineOperand &MO = FoldMI->getOperand(i - 1);
|
||||
if (!MO.isReg() || !MO.isImplicit())
|
||||
break;
|
||||
if (MO.getReg() == ImpReg)
|
||||
FoldMI->RemoveOperand(i - 1);
|
||||
}
|
||||
|
||||
DEBUG(dbgs() << "\tfolded: " << LIS.getInstructionIndex(FoldMI) << '\t'
|
||||
<< *FoldMI);
|
||||
if (!WasCopy)
|
||||
++NumFolded;
|
||||
else if (Ops.front() == 0)
|
||||
|
Reference in New Issue
Block a user