[AMDGPU] Fix DEALLOC_VGPRS in the presence of spills to scratch (#178461)

This commit is contained in:
Jay Foad 2026-01-29 19:57:16 +00:00 committed by GitHub
parent a617b901cd
commit dbd4240130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View File

@ -4482,14 +4482,15 @@ bool SIInstrInfo::mayAccessScratch(const MachineInstr &MI) const {
if ((!isFLAT(MI) || isFLATGlobal(MI)) && !isBUF(MI))
return false;
// If scratch is not initialized, we can never access it.
if (MI.getMF()->getFunction().hasFnAttribute("amdgpu-no-flat-scratch-init"))
return false;
// SCRATCH instructions always access scratch.
if (isFLATScratch(MI))
return true;
// If FLAT_SCRATCH registers are not initialized, we can never access scratch
// via the aperture.
if (MI.getMF()->getFunction().hasFnAttribute("amdgpu-no-flat-scratch-init"))
return false;
// If there are no memory operands then conservatively assume the flat
// operation may access scratch.
if (MI.memoperands_empty())

View File

@ -3,7 +3,7 @@
; This function uses scratch_store to spill some values to the stack. While
; these stores are potentially outstanding it should not send the DEALLOC_VGPRS
; message. FIXME.
; message.
define amdgpu_kernel void @f(ptr %ptr, i32 %arg) "amdgpu-flat-work-group-size"="64,64" {
; CHECK-LABEL: f:
@ -32,8 +32,6 @@ define amdgpu_kernel void @f(ptr %ptr, i32 %arg) "amdgpu-flat-work-group-size"="
; CHECK-NEXT: s_waitcnt vmcnt(0)
; CHECK-NEXT: global_store_b32 v[0:1], v2, off
; CHECK-NEXT: .LBB0_2: ; %false
; CHECK-NEXT: s_nop 0
; CHECK-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
; CHECK-NEXT: s_endpgm
%tid = call i32 @llvm.amdgcn.workitem.id.x()
%gep = getelementptr i32, ptr %ptr, i32 %tid