Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit 9933a17

Browse files
author
Dylan McKay
committed
[RegAllocGreedy] Attempt to split unspillable live intervals
Previously, when allocating unspillable live ranges, we would never attempt to split. We would always bail out and try last ditch graph recoloring. This patch changes this by attempting to split all live intervals before performing recoloring.
1 parent b705c4b commit 9933a17

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

lib/CodeGen/CalcSpillWeights.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,7 @@ VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &li) {
221221
// spilling may be required.
222222
if (li.isZeroLength(LIS.getSlotIndexes()) &&
223223
!li.isLiveAtIndexes(LIS.getRegMaskSlots())) {
224-
// HACK HACK: This is a workaround until PR14879 gets fixed!
225-
// This code allows us to compile memory intensive functions when only the Z
226-
// register is available, otherwise we get the "Ran out of registers ..."
227-
// assertion inside the regalloc.
228-
// Here we avoid marking as not spillable live intervals that use the
229-
// PTRDISPREGS class and have a size greater than 8, smaller ones
230-
// get filtered out, generating better code.
231-
if (strcmp(MF.getSubtarget().getRegisterInfo()->getRegClassName(mri.getRegClass(li.reg)), "PTRDISPREGS") == 0 &&
232-
li.getSize() > 8) {
233-
totalWeight *= 10000.0F;
234-
li.weight = normalizeSpillWeight(totalWeight, li.getSize(), numInstr);
235-
} else {
236-
li.markNotSpillable();
237-
}
224+
li.markNotSpillable();
238225
return;
239226
}
240227

lib/CodeGen/RegAllocGreedy.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -2588,18 +2588,20 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
25882588
return 0;
25892589
}
25902590

2591+
if (Stage == RS_Split || Stage == RS_Split2) {
2592+
// Try splitting VirtReg or interferences.
2593+
unsigned NewVRegSizeBefore = NewVRegs.size();
2594+
unsigned PhysReg = trySplit(VirtReg, Order, NewVRegs);
2595+
if (PhysReg || (NewVRegs.size() - NewVRegSizeBefore))
2596+
return PhysReg;
2597+
}
2598+
25912599
// If we couldn't allocate a register from spilling, there is probably some
25922600
// invalid inline assembly. The base class wil report it.
25932601
if (Stage >= RS_Done || !VirtReg.isSpillable())
25942602
return tryLastChanceRecoloring(VirtReg, Order, NewVRegs, FixedRegisters,
25952603
Depth);
25962604

2597-
// Try splitting VirtReg or interferences.
2598-
unsigned NewVRegSizeBefore = NewVRegs.size();
2599-
unsigned PhysReg = trySplit(VirtReg, Order, NewVRegs);
2600-
if (PhysReg || (NewVRegs.size() - NewVRegSizeBefore))
2601-
return PhysReg;
2602-
26032605
// Finally spill VirtReg itself.
26042606
if (EnableDeferredSpilling && getStage(VirtReg) < RS_Memory) {
26052607
// TODO: This is experimental and in particular, we do not model

test/CodeGen/AVR/high-pressure-on-ptrregs.ll

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
;
1111
; There is an existing bug filed for this issue - PR14879.
1212
;
13-
; LLVM should be able to handle this elegantly, because PTRREGS is a
14-
; subset of DREGS, so we should be able to do cross-class copies in
15-
; order to complete register allocation.
16-
;
1713
; The specific failure:
1814
; LLVM ERROR: ran out of registers during register allocation
1915
;

0 commit comments

Comments
 (0)