Don't count register uses when determining the maximum number of registers used by a function. Count only the defs. This is really an underestimate of the true register usage, but in practice that's not a problem because if a function uses a register, then it has either defined it earlier, or some other function that executed before has defined it. In particular, the register counts are used: 1. When launching an entry function - in which case we're safe because the register counts of the entry function will include the register counts of all callees. 2. At function boundaries in dynamic VGPR mode. In this case it's safe because whenever we set the new VGPR allocation we take into account the outgoing_vgpr_count set by the middle-end. The main advantage of doing this is that the artificial VGPR arguments used only for preserving the inactive lanes when using the llvm.amdgcn.init.whole.wave intrinsic are no longer counted. This enables us to allocate only the registers we need in dynamic VGPR mode. --------- Co-authored-by: Thomas Symalla <5754458+tsymalla@users.noreply.github.com>
49 lines
2.2 KiB
LLVM
49 lines
2.2 KiB
LLVM
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 < %s | FileCheck %s
|
|
|
|
; CHECK-LABEL: __unnamed_1:
|
|
; CHECK: .set __unnamed_1.num_vgpr, 0
|
|
; CHECK: .set __unnamed_1.num_agpr, 0
|
|
; CHECK: .set __unnamed_1.numbered_sgpr, 0
|
|
; CHECK: .set __unnamed_1.private_seg_size, 0
|
|
; CHECK: .set __unnamed_1.uses_vcc, 0
|
|
; CHECK: .set __unnamed_1.uses_flat_scratch, 0
|
|
; CHECK: .set __unnamed_1.has_dyn_sized_stack, 0
|
|
; CHECK: .set __unnamed_1.has_recursion, 0
|
|
; CHECK: .set __unnamed_1.has_indirect_call, 0
|
|
define void @1() {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: __unnamed_2:
|
|
; CHECK: .set __unnamed_2.num_vgpr, max(1, __unnamed_1.num_vgpr)
|
|
; CHECK: .set __unnamed_2.num_agpr, max(0, __unnamed_1.num_agpr)
|
|
; CHECK: .set __unnamed_2.numbered_sgpr, max(34, __unnamed_1.numbered_sgpr)
|
|
; CHECK: .set __unnamed_2.private_seg_size, 16+max(__unnamed_1.private_seg_size)
|
|
; CHECK: .set __unnamed_2.uses_vcc, or(0, __unnamed_1.uses_vcc)
|
|
; CHECK: .set __unnamed_2.uses_flat_scratch, or(0, __unnamed_1.uses_flat_scratch)
|
|
; CHECK: .set __unnamed_2.has_dyn_sized_stack, or(0, __unnamed_1.has_dyn_sized_stack)
|
|
; CHECK: .set __unnamed_2.has_recursion, or(1, __unnamed_1.has_recursion)
|
|
; CHECK: .set __unnamed_2.has_indirect_call, or(0, __unnamed_1.has_indirect_call)
|
|
define void @2() {
|
|
entry:
|
|
call void @1()
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: {{^}}use
|
|
; CHECK: .set use.num_vgpr, max(32, __unnamed_1.num_vgpr, __unnamed_2.num_vgpr)
|
|
; CHECK: .set use.num_agpr, max(0, __unnamed_1.num_agpr, __unnamed_2.num_agpr)
|
|
; CHECK: .set use.numbered_sgpr, max(33, __unnamed_1.numbered_sgpr, __unnamed_2.numbered_sgpr)
|
|
; CHECK: .set use.private_seg_size, 0+max(__unnamed_1.private_seg_size, __unnamed_2.private_seg_size)
|
|
; CHECK: .set use.uses_vcc, or(0, __unnamed_1.uses_vcc, __unnamed_2.uses_vcc)
|
|
; CHECK: .set use.uses_flat_scratch, or(1, __unnamed_1.uses_flat_scratch, __unnamed_2.uses_flat_scratch)
|
|
; CHECK: .set use.has_dyn_sized_stack, or(0, __unnamed_1.has_dyn_sized_stack, __unnamed_2.has_dyn_sized_stack)
|
|
; CHECK: .set use.has_recursion, or(1, __unnamed_1.has_recursion, __unnamed_2.has_recursion)
|
|
; CHECK: .set use.has_indirect_call, or(0, __unnamed_1.has_indirect_call, __unnamed_2.has_indirect_call)
|
|
define amdgpu_kernel void @use() {
|
|
call void @1()
|
|
call void @2()
|
|
ret void
|
|
}
|