mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Teach VirtRegRewriter to handle spilling in instructions that have multiple
definitions of the virtual register. This happens when spilling the registers produced by REG_SEQUENCE: %reg1047:5<def>, %reg1047:6<def>, %reg1047:7<def> = VLD3d8 %reg1033, 0, pred:14, pred:%reg0 The rewriter would spill the register multiple times, dead store elimination tried to keep up, but ended up cutting the branch it was sitting on. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104321 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1895,6 +1895,11 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
|
||||
|
||||
// Clear kill info.
|
||||
SmallSet<unsigned, 2> KilledMIRegs;
|
||||
|
||||
// Keep track of the registers we have already spilled in case there are
|
||||
// multiple defs of the same register in MI.
|
||||
SmallSet<unsigned, 8> SpilledMIRegs;
|
||||
|
||||
RegKills.reset();
|
||||
KillOps.clear();
|
||||
KillOps.resize(TRI->getNumRegs(), NULL);
|
||||
@@ -2412,6 +2417,7 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
|
||||
}
|
||||
|
||||
// Process all of the spilled defs.
|
||||
SpilledMIRegs.clear();
|
||||
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI.getOperand(i);
|
||||
if (!(MO.isReg() && MO.getReg() && MO.isDef()))
|
||||
@@ -2505,7 +2511,7 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
|
||||
MI.getOperand(i).setReg(RReg);
|
||||
MI.getOperand(i).setSubReg(0);
|
||||
|
||||
if (!MO.isDead()) {
|
||||
if (!MO.isDead() && SpilledMIRegs.insert(VirtReg)) {
|
||||
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
|
||||
SpillRegToStackSlot(MII, -1, PhysReg, StackSlot, RC, true,
|
||||
LastStore, Spills, ReMatDefs, RegKills, KillOps);
|
||||
|
||||
Reference in New Issue
Block a user