Skip to content

Commit 0f84c63

Browse files
committed
Move where undef sgpr spills are deleted
1 parent 3db8f1e commit 0f84c63

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@ bool SILowerSGPRSpills::run(MachineFunction &MF) {
422422
if (!TII->isSGPRSpill(MI))
423423
continue;
424424

425+
if (MI.getOperand(0).isUndef()) {
426+
if (Indexes)
427+
Indexes->removeMachineInstrFromMaps(MI);
428+
MI.eraseFromParent();
429+
continue;
430+
}
431+
425432
int FI = TII->getNamedOperand(MI, AMDGPU::OpName::addr)->getIndex();
426433
assert(MFI.getStackID(FI) == TargetStackID::SGPRSpill);
427434

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,12 +1954,8 @@ bool SIRegisterInfo::spillSGPR(MachineBasicBlock::iterator MI, int Index,
19541954
RegScavenger *RS, SlotIndexes *Indexes,
19551955
LiveIntervals *LIS, bool OnlyToVGPR,
19561956
bool SpillToPhysVGPRLane) const {
1957-
if (MI->getOperand(0).isUndef()) {
1958-
if (Indexes)
1959-
Indexes->removeMachineInstrFromMaps(*MI);
1960-
MI->eraseFromParent();
1961-
return true;
1962-
}
1957+
assert(!MI->getOperand(0).isUndef() &&
1958+
"undef spill should have been deleted earlier");
19631959

19641960
SGPRSpillBuilder SB(*this, *ST.getInstrInfo(), isWave32, MI, Index, RS);
19651961

0 commit comments

Comments
 (0)