Skip to content

Commit e0042c9

Browse files
committed
Save NumWaveDispatchRegs in MFI for kernels
1 parent 564a98b commit e0042c9

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -997,28 +997,20 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo,
997997
unsigned WaveDispatchNumSGPR = MFI->getNumWaveDispatchSGPRs(),
998998
WaveDispatchNumVGPR = MFI->getNumWaveDispatchVGPRs();
999999

1000-
// FIXME: Cleanup
1001-
if (isShader(F.getCallingConv())) {
1000+
if (WaveDispatchNumSGPR) {
10021001
ProgInfo.NumSGPR = AMDGPUMCExpr::createMax(
10031002
{ProgInfo.NumSGPR,
10041003
MCBinaryExpr::createAdd(CreateExpr(WaveDispatchNumSGPR), ExtraSGPRs,
10051004
Ctx)},
10061005
Ctx);
1006+
}
10071007

1008+
if (WaveDispatchNumVGPR) {
10081009
ProgInfo.NumArchVGPR = AMDGPUMCExpr::createMax(
10091010
{ProgInfo.NumVGPR, CreateExpr(WaveDispatchNumVGPR)}, Ctx);
10101011

10111012
ProgInfo.NumVGPR = AMDGPUMCExpr::createTotalNumVGPR(
10121013
ProgInfo.NumAccVGPR, ProgInfo.NumArchVGPR, Ctx);
1013-
} else if (isKernel(F.getCallingConv()) &&
1014-
MFI->getNumKernargPreloadedSGPRs()) {
1015-
// Consider cases where the total number of UserSGPRs with trailing
1016-
// allocated preload SGPRs, is greater than the number of explicitly
1017-
// referenced SGPRs.
1018-
const MCExpr *UserPlusExtraSGPRs = MCBinaryExpr::createAdd(
1019-
CreateExpr(MFI->getNumUserSGPRs()), ExtraSGPRs, Ctx);
1020-
ProgInfo.NumSGPR =
1021-
AMDGPUMCExpr::createMax({ProgInfo.NumSGPR, UserPlusExtraSGPRs}, Ctx);
10221014
}
10231015

10241016
// Adjust number of registers used to meet default/requested minimum/maximum

llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ bool AMDGPUCallLowering::lowerFormalArgumentsKernel(
580580
++i;
581581
}
582582

583+
if (Info->getNumKernargPreloadedSGPRs())
584+
Info->setNumWaveDispatchSGPRs(Info->getNumUserSGPRs());
585+
583586
TLI.allocateSpecialEntryInputVGPRs(CCInfo, MF, *TRI, *Info);
584587
TLI.allocateSystemSGPRs(CCInfo, MF, *Info, F.getCallingConv(), false);
585588
return true;

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,6 +3106,8 @@ SDValue SITargetLowering::LowerFormalArguments(
31063106
CCInfo.getFirstUnallocated(AMDGPU::SGPR_32RegClass.getRegisters()));
31073107
Info->setNumWaveDispatchVGPRs(
31083108
CCInfo.getFirstUnallocated(AMDGPU::VGPR_32RegClass.getRegisters()));
3109+
} else if (Info->getNumKernargPreloadedSGPRs()) {
3110+
Info->setNumWaveDispatchSGPRs(Info->getNumUserSGPRs());
31093111
}
31103112

31113113
SmallVector<SDValue, 16> Chains;

0 commit comments

Comments
 (0)