Skip to content

Commit 733e0a8

Browse files
committed
[AMDGPU] Merge the conditions used for deciding CS spills for amdgpu_cs_chain[_preserve] (llvm#109911)
Multiple conditions exist to decide whether callee save spills/restores are required for amdgpu_cs_chain or amdgpu_cs_chain_preserve calling conventions. This patch consolidates them all and moves to a single place. Change-Id: Iceb4609d0b9505ea3ec09023887d4e9261d8d033
1 parent 6c8905e commit 733e0a8

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

llvm/lib/Target/AMDGPU/SIFrameLowering.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,16 +1607,10 @@ void SIFrameLowering::processFunctionBeforeFrameFinalized(
16071607
SIMachineFunctionInfo *FuncInfo = MF.getInfo<SIMachineFunctionInfo>();
16081608

16091609
// Allocate spill slots for WWM reserved VGPRs.
1610-
// For chain functions, we only need to do this if we have calls to
1611-
// llvm.amdgcn.cs.chain.
1612-
bool IsChainWithoutCalls =
1613-
FuncInfo->isChainFunction() && !MF.getFrameInfo().hasTailCall();
1614-
if (!FuncInfo->isEntryFunction() && !IsChainWithoutCalls) {
1615-
for (Register Reg : FuncInfo->getWWMReservedRegs()) {
1616-
const TargetRegisterClass *RC = TRI->getPhysRegBaseClass(Reg);
1617-
FuncInfo->allocateWWMSpill(MF, Reg, TRI->getSpillSize(*RC),
1618-
TRI->getSpillAlign(*RC));
1619-
}
1610+
for (Register Reg : FuncInfo->getWWMReservedRegs()) {
1611+
const TargetRegisterClass *RC = TRI->getPhysRegBaseClass(Reg);
1612+
FuncInfo->allocateWWMSpill(MF, Reg, TRI->getSpillSize(*RC),
1613+
TRI->getSpillAlign(*RC));
16201614
}
16211615

16221616
const bool SpillVGPRToAGPR = ST.hasMAIInsts() && FuncInfo->hasSpilledVGPRs()

llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ void SIMachineFunctionInfo::allocateWWMSpill(MachineFunction &MF, Register VGPR,
288288
// amdgpu_cs_chain_preserve calling convention and this is a scratch register.
289289
// We never need to allocate a spill for these because we don't even need to
290290
// restore the inactive lanes for them (they're scratchier than the usual
291-
// scratch registers).
292-
if (isChainFunction() && SIRegisterInfo::isChainScratchRegister(VGPR))
291+
// scratch registers). We only need to do this if we have calls to
292+
// llvm.amdgcn.cs.chain.
293+
if (isChainFunction() && (SIRegisterInfo::isChainScratchRegister(VGPR) ||
294+
!MF.getFrameInfo().hasTailCall()))
293295
return;
294296

295297
WWMSpills.insert(std::make_pair(

0 commit comments

Comments
 (0)