mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-11 10:25:41 +00:00
Avoid hoisting spills when looking at a copy from another register that is also
about to be spilled. This can only happen when two extra snippet registers are included in the spill, and there is a copy between them. Hoisting the spill creates problems because the hoist will mark the copy for later dead code elimination, and spilling the second register will turn the copy into a spill. <rdar://problem/9420853> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131192 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -855,6 +855,7 @@ void InlineSpiller::insertSpill(LiveInterval &NewLI, const LiveInterval &OldLI,
|
|||||||
|
|
||||||
/// spillAroundUses - insert spill code around each use of Reg.
|
/// spillAroundUses - insert spill code around each use of Reg.
|
||||||
void InlineSpiller::spillAroundUses(unsigned Reg) {
|
void InlineSpiller::spillAroundUses(unsigned Reg) {
|
||||||
|
DEBUG(dbgs() << "spillAroundUses " << PrintReg(Reg) << '\n');
|
||||||
LiveInterval &OldLI = LIS.getInterval(Reg);
|
LiveInterval &OldLI = LIS.getInterval(Reg);
|
||||||
|
|
||||||
// Iterate over instructions using Reg.
|
// Iterate over instructions using Reg.
|
||||||
@@ -902,6 +903,12 @@ void InlineSpiller::spillAroundUses(unsigned Reg) {
|
|||||||
// Check for a sibling copy.
|
// Check for a sibling copy.
|
||||||
unsigned SibReg = isFullCopyOf(MI, Reg);
|
unsigned SibReg = isFullCopyOf(MI, Reg);
|
||||||
if (SibReg && isSibling(SibReg)) {
|
if (SibReg && isSibling(SibReg)) {
|
||||||
|
// This may actually be a copy between snippets.
|
||||||
|
if (isRegToSpill(SibReg)) {
|
||||||
|
DEBUG(dbgs() << "Found new snippet copy: " << *MI);
|
||||||
|
SnippetCopies.insert(MI);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (Writes) {
|
if (Writes) {
|
||||||
// Hoist the spill of a sib-reg copy.
|
// Hoist the spill of a sib-reg copy.
|
||||||
if (hoistSpill(OldLI, MI)) {
|
if (hoistSpill(OldLI, MI)) {
|
||||||
@@ -983,13 +990,15 @@ void InlineSpiller::spillAll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally delete the SnippetCopies.
|
// Finally delete the SnippetCopies.
|
||||||
for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit->getReg());
|
for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) {
|
||||||
MachineInstr *MI = RI.skipInstruction();) {
|
for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(RegsToSpill[i]);
|
||||||
assert(SnippetCopies.count(MI) && "Remaining use wasn't a snippet copy");
|
MachineInstr *MI = RI.skipInstruction();) {
|
||||||
// FIXME: Do this with a LiveRangeEdit callback.
|
assert(SnippetCopies.count(MI) && "Remaining use wasn't a snippet copy");
|
||||||
VRM.RemoveMachineInstrFromMaps(MI);
|
// FIXME: Do this with a LiveRangeEdit callback.
|
||||||
LIS.RemoveMachineInstrFromMaps(MI);
|
VRM.RemoveMachineInstrFromMaps(MI);
|
||||||
MI->eraseFromParent();
|
LIS.RemoveMachineInstrFromMaps(MI);
|
||||||
|
MI->eraseFromParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all spilled registers.
|
// Delete all spilled registers.
|
||||||
|
Reference in New Issue
Block a user