diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -2112,7 +2112,8 @@ SIMachineFunctionInfo &Info, CallingConv::ID CallConv, bool IsShader) const { - if (Subtarget->hasUserSGPRInit16Bug()) { + if (Subtarget->hasUserSGPRInit16Bug() && !IsShader) { + // Note: user SGPRs are handled by the front-end for graphics shaders // Pad up the used user SGPRs with dead inputs. unsigned CurrentUserSGPRs = Info.getNumUserSGPRs(); @@ -2175,7 +2176,8 @@ CCInfo.AllocateReg(PrivateSegmentWaveByteOffsetReg); } - assert(!Subtarget->hasUserSGPRInit16Bug() || Info.getNumPreloadedSGPRs() >= 16); + assert(!Subtarget->hasUserSGPRInit16Bug() || IsShader || + Info.getNumPreloadedSGPRs() >= 16); } static void reservePrivateMemoryRegs(const TargetMachine &TM,