Skip to content

Commit 4db4d7f

Browse files
authored
[AMDGPU] SILowerSGPRSpills: do not update MRI reserve registers (#77888)
VGPRs used for spilling do not require explicit reservation with MRI. freezeReservedRegs() executed before register allocation ensures these are placed in the reserve set. The only pass after SILowerSGPRSpills is SIPreAllocateWWMRegs which explicitly tests for interference before register allocation so should not reuse a WWM VGPR holding spill data. reserveReg prevents calculation of correct liveness for physical registers which could be used to extend SIPreAllocateWWMRegs.
1 parent d4933b3 commit 4db4d7f

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ bool SILowerSGPRSpills::runOnMachineFunction(MachineFunction &MF) {
332332
}
333333

334334
bool MadeChange = false;
335-
bool NewReservedRegs = false;
336335
bool SpilledToVirtVGPRLanes = false;
337336

338337
// TODO: CSR VGPRs will never be spilled to AGPRs. These can probably be
@@ -370,7 +369,6 @@ bool SILowerSGPRSpills::runOnMachineFunction(MachineFunction &MF) {
370369
// intermediate spills is implemented. There is no such support
371370
// currently exist in the LLVM compiler.
372371
if (FuncInfo->allocateSGPRSpillToVGPRLane(MF, FI, true)) {
373-
NewReservedRegs = true;
374372
bool Spilled = TRI->eliminateSGPRToVGPRSpillFrameIndex(
375373
MI, FI, nullptr, Indexes, LIS, true);
376374
if (!Spilled)
@@ -442,12 +440,5 @@ bool SILowerSGPRSpills::runOnMachineFunction(MachineFunction &MF) {
442440
SaveBlocks.clear();
443441
RestoreBlocks.clear();
444442

445-
// Updated the reserved registers with any physical VGPRs added for SGPR
446-
// spills.
447-
if (NewReservedRegs) {
448-
for (Register Reg : FuncInfo->getWWMReservedRegs())
449-
MRI.reserveReg(Reg, TRI);
450-
}
451-
452443
return MadeChange;
453444
}

llvm/test/CodeGen/AMDGPU/sgpr-spill-overlap-wwm-reserve.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2-
# RUN: llc -mtriple=amdgcn-unknown-amdpal -mcpu=gfx1030 -start-before=si-lower-sgpr-spills -stop-after=prologepilog -verify-machineinstrs --stress-regalloc=2 -o - %s | FileCheck -check-prefix GCN %s
2+
# RUN: llc -mtriple=amdgcn-unknown-amdpal -mcpu=gfx1030 -start-before=si-lower-sgpr-spills -stop-after=prologepilog -verify-machineinstrs --stress-regalloc=5 -o - %s | FileCheck -check-prefix GCN %s
33

44
--- |
55
define amdgpu_gfx [13 x i32] @test_main() #0 {

0 commit comments

Comments
 (0)