mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 18:24:38 +00:00
Fixed a long standing spiller bug that's exposed by Thumb:
The code sequence before the spiller is something like: = tMOVrr %reg1117 = tMOVrr %reg1078 = tLSLri %reg1117, 2 The it starts spilling: %r0 = tRestore <fi#5>, 0 %r1 = tRestore <fi#7>, 0 %r1 = tMOVrr %r1<kill> tSpill %r1, <fi#5>, 0 %reg1078 = tLSLri %reg1117, 2 It restores the value while processing the first tMOVrr. At this point, the spiller remembers fi#5 is available in %r0. Next it processes the second move. It restores the source before the move and spills the result afterwards. The move becomes a noop and is deleted. However, a spill has been inserted and that should invalidate reuse of %r0 for fi#5 and add reuse of %r1 for fi#5. Therefore, %reg1117 (which is also assigned fi#5) should get %r1, not %r0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -923,19 +923,6 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
DOUT << "Store:\t" << *next(MII);
|
DOUT << "Store:\t" << *next(MII);
|
||||||
MI.getOperand(i).setReg(PhysReg);
|
MI.getOperand(i).setReg(PhysReg);
|
||||||
|
|
||||||
// Check to see if this is a noop copy. If so, eliminate the
|
|
||||||
// instruction before considering the dest reg to be changed.
|
|
||||||
{
|
|
||||||
unsigned Src, Dst;
|
|
||||||
if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
|
|
||||||
++NumDCE;
|
|
||||||
DOUT << "Removing now-noop copy: " << MI;
|
|
||||||
MBB.erase(&MI);
|
|
||||||
VRM.RemoveFromFoldedVirtMap(&MI);
|
|
||||||
goto ProcessNextInst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there is a dead store to this stack slot, nuke it now.
|
// If there is a dead store to this stack slot, nuke it now.
|
||||||
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
|
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
|
||||||
if (LastStore) {
|
if (LastStore) {
|
||||||
@ -953,6 +940,19 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
Spills.ClobberPhysReg(PhysReg);
|
Spills.ClobberPhysReg(PhysReg);
|
||||||
Spills.addAvailable(StackSlot, PhysReg);
|
Spills.addAvailable(StackSlot, PhysReg);
|
||||||
++NumStores;
|
++NumStores;
|
||||||
|
|
||||||
|
// Check to see if this is a noop copy. If so, eliminate the
|
||||||
|
// instruction before considering the dest reg to be changed.
|
||||||
|
{
|
||||||
|
unsigned Src, Dst;
|
||||||
|
if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
|
||||||
|
++NumDCE;
|
||||||
|
DOUT << "Removing now-noop copy: " << MI;
|
||||||
|
MBB.erase(&MI);
|
||||||
|
VRM.RemoveFromFoldedVirtMap(&MI);
|
||||||
|
goto ProcessNextInst;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessNextInst:
|
ProcessNextInst:
|
||||||
|
Reference in New Issue
Block a user