Skip to content

[AMDGPU] No available SGPR for CSR spill stores #113782

Closed
@shiltian

Description

@shiltian

In emitCSRSpillStores, a caller-saved SGPR is required to save exec, which limits us to using SGPR0 through SGPR29. Currently, we assume that one is always available; however, this isn’t always the case, as SGPR0 to SGPR29 are also used for inreg argument passing.

https://github.com/llvm/llvm-project/blob/3b7d788ff22b8aa22634b927faf01da12bece496/llvm/lib/Target/AMDGPU/SIFrameLowering.cpp#L966

If there are enough inreg arguments, no SGPR is available, leading to a compiler crash. The following example demonstrates this issue.

; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 %s -o -

declare hidden void @external_void_func_a15i32_inreg([16 x i32] inreg)

define void @test_call_external_void_func_a15i32_inreg([16 x i32] inreg %arg0) {
  call void @external_void_func_a15i32_inreg([16 x i32] inreg %arg0)
  ret void
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions