diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-10-28 19:43:31 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-10-28 19:43:31 +0000 |
commit | 08906a3c62b7700bafda4de8a1538433abd69be9 (patch) | |
tree | a4a6091fb04ad117b430b94c127503c2555b301b /llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | |
parent | e28a0fc72a345ede4ef9d137a15d9c102f427931 (diff) | |
download | bcm5719-llvm-08906a3c62b7700bafda4de8a1538433abd69be9.tar.gz bcm5719-llvm-08906a3c62b7700bafda4de8a1538433abd69be9.zip |
AMDGPU: Fix using incorrect private resource with no allocation
It's possible to have a use of the private resource descriptor or
scratch wave offset registers even though there are no allocated
stack objects. This would result in continuing to use the maximum
number reserved registers. This could go over the number of SGPRs
available on VI, or violate the SGPR limit requested by
the function attributes.
llvm-svn: 285435
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp index 5bb7024e65e..9a35a992b54 100644 --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp @@ -1059,9 +1059,20 @@ unsigned SIRegisterInfo::getMaxNumSGPRs(const MachineFunction &MF) const { F, "amdgpu-num-sgpr", MaxNumSGPRs); // Make sure requested value does not violate subtarget's specifications. - if (Requested && Requested <= getNumReservedSGPRs(ST)) + if (Requested && (Requested <= getNumReservedSGPRs(ST))) Requested = 0; + // If more SGPRs are required to support the input user/system SGPRs, + // increase to accomodate them. + // + // FIXME: This really ends up using the requested number of SGPRs + number + // of reserved special registers in total. Theoretically you could re-use + // the last input registers for these special registers, but this would + // require a lot of complexity to deal with the weird aliasing. + unsigned NumInputSGPRs = MFI.getNumPreloadedSGPRs(); + if (Requested && Requested < NumInputSGPRs) + Requested = NumInputSGPRs; + // Make sure requested value is compatible with values implied by // default/requested minimum/maximum number of waves per execution unit. if (Requested && Requested > getMaxNumSGPRs(ST, WavesPerEU.first)) |