RegAlloc: Allow targets to split register allocation
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register
classes are handled at the same time, this was problematic. We don't
know ahead of time how many registers will be needed to be reserved to
handle the spilling. If no VGPRs were left for spilling, we would have
to try to spill to memory. If the spilled SGPRs were required for exec
mask manipulation, it is highly problematic because the lanes active
at the point of spill are not necessarily the same as at the restore
point.
Avoid this problem by fully allocating SGPRs in a separate regalloc
run from VGPRs. This way we know the exact number of VGPRs needed, and
can reserve them for a second run. This fixes the most serious
issues, but it is still possible using inline asm to make all VGPRs
unavailable. Start erroring in the case where we ever would require
memory for an SGPR spill.
This is implemented by giving each regalloc pass a callback which
reports if a register class should be handled or not. A few passes
need some small changes to deal with leftover virtual registers.
In the AMDGPU implementation, a new pass is introduced to take the
place of PrologEpilogInserter for SGPR spills emitted during the first
run.
One disadvantage of this is currently StackSlotColoring is no longer
used for SGPR spills. It would need to be run again, which will
require more work.
Error if the standard -regalloc option is used. Introduce new separate
-sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be
controlled individually. PBQB is not currently supported, so this also
prevents using the unhandled allocator.
2018-09-27 01:36:28 +02:00
|
|
|
; REQUIRES: asserts
|
|
|
|
|
2021-07-14 01:33:38 +02:00
|
|
|
; RUN: llc -verify-machineinstrs=0 -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
|
|
|
|
; RUN: llc -verify-machineinstrs=0 -sgpr-regalloc=greedy -vgpr-regalloc=greedy -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
|
RegAlloc: Allow targets to split register allocation
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register
classes are handled at the same time, this was problematic. We don't
know ahead of time how many registers will be needed to be reserved to
handle the spilling. If no VGPRs were left for spilling, we would have
to try to spill to memory. If the spilled SGPRs were required for exec
mask manipulation, it is highly problematic because the lanes active
at the point of spill are not necessarily the same as at the restore
point.
Avoid this problem by fully allocating SGPRs in a separate regalloc
run from VGPRs. This way we know the exact number of VGPRs needed, and
can reserve them for a second run. This fixes the most serious
issues, but it is still possible using inline asm to make all VGPRs
unavailable. Start erroring in the case where we ever would require
memory for an SGPR spill.
This is implemented by giving each regalloc pass a callback which
reports if a register class should be handled or not. A few passes
need some small changes to deal with leftover virtual registers.
In the AMDGPU implementation, a new pass is introduced to take the
place of PrologEpilogInserter for SGPR spills emitted during the first
run.
One disadvantage of this is currently StackSlotColoring is no longer
used for SGPR spills. It would need to be run again, which will
require more work.
Error if the standard -regalloc option is used. Introduce new separate
-sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be
controlled individually. PBQB is not currently supported, so this also
prevents using the unhandled allocator.
2018-09-27 01:36:28 +02:00
|
|
|
|
2021-07-14 01:33:38 +02:00
|
|
|
; RUN: llc -verify-machineinstrs=0 -O0 -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=O0 %s
|
RegAlloc: Allow targets to split register allocation
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register
classes are handled at the same time, this was problematic. We don't
know ahead of time how many registers will be needed to be reserved to
handle the spilling. If no VGPRs were left for spilling, we would have
to try to spill to memory. If the spilled SGPRs were required for exec
mask manipulation, it is highly problematic because the lanes active
at the point of spill are not necessarily the same as at the restore
point.
Avoid this problem by fully allocating SGPRs in a separate regalloc
run from VGPRs. This way we know the exact number of VGPRs needed, and
can reserve them for a second run. This fixes the most serious
issues, but it is still possible using inline asm to make all VGPRs
unavailable. Start erroring in the case where we ever would require
memory for an SGPR spill.
This is implemented by giving each regalloc pass a callback which
reports if a register class should be handled or not. A few passes
need some small changes to deal with leftover virtual registers.
In the AMDGPU implementation, a new pass is introduced to take the
place of PrologEpilogInserter for SGPR spills emitted during the first
run.
One disadvantage of this is currently StackSlotColoring is no longer
used for SGPR spills. It would need to be run again, which will
require more work.
Error if the standard -regalloc option is used. Introduce new separate
-sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be
controlled individually. PBQB is not currently supported, so this also
prevents using the unhandled allocator.
2018-09-27 01:36:28 +02:00
|
|
|
|
2021-07-14 01:33:38 +02:00
|
|
|
; RUN: llc -verify-machineinstrs=0 -vgpr-regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=DEFAULT-BASIC %s
|
|
|
|
; RUN: llc -verify-machineinstrs=0 -sgpr-regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=BASIC-DEFAULT %s
|
|
|
|
; RUN: llc -verify-machineinstrs=0 -sgpr-regalloc=basic -vgpr-regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=BASIC-BASIC %s
|
RegAlloc: Allow targets to split register allocation
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register
classes are handled at the same time, this was problematic. We don't
know ahead of time how many registers will be needed to be reserved to
handle the spilling. If no VGPRs were left for spilling, we would have
to try to spill to memory. If the spilled SGPRs were required for exec
mask manipulation, it is highly problematic because the lanes active
at the point of spill are not necessarily the same as at the restore
point.
Avoid this problem by fully allocating SGPRs in a separate regalloc
run from VGPRs. This way we know the exact number of VGPRs needed, and
can reserve them for a second run. This fixes the most serious
issues, but it is still possible using inline asm to make all VGPRs
unavailable. Start erroring in the case where we ever would require
memory for an SGPR spill.
This is implemented by giving each regalloc pass a callback which
reports if a register class should be handled or not. A few passes
need some small changes to deal with leftover virtual registers.
In the AMDGPU implementation, a new pass is introduced to take the
place of PrologEpilogInserter for SGPR spills emitted during the first
run.
One disadvantage of this is currently StackSlotColoring is no longer
used for SGPR spills. It would need to be run again, which will
require more work.
Error if the standard -regalloc option is used. Introduce new separate
-sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be
controlled individually. PBQB is not currently supported, so this also
prevents using the unhandled allocator.
2018-09-27 01:36:28 +02:00
|
|
|
|
2021-07-14 01:33:38 +02:00
|
|
|
; RUN: not --crash llc -verify-machineinstrs=0 -regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s
|
|
|
|
; RUN: not --crash llc -verify-machineinstrs=0 -regalloc=fast -O0 -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s
|
RegAlloc: Allow targets to split register allocation
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register
classes are handled at the same time, this was problematic. We don't
know ahead of time how many registers will be needed to be reserved to
handle the spilling. If no VGPRs were left for spilling, we would have
to try to spill to memory. If the spilled SGPRs were required for exec
mask manipulation, it is highly problematic because the lanes active
at the point of spill are not necessarily the same as at the restore
point.
Avoid this problem by fully allocating SGPRs in a separate regalloc
run from VGPRs. This way we know the exact number of VGPRs needed, and
can reserve them for a second run. This fixes the most serious
issues, but it is still possible using inline asm to make all VGPRs
unavailable. Start erroring in the case where we ever would require
memory for an SGPR spill.
This is implemented by giving each regalloc pass a callback which
reports if a register class should be handled or not. A few passes
need some small changes to deal with leftover virtual registers.
In the AMDGPU implementation, a new pass is introduced to take the
place of PrologEpilogInserter for SGPR spills emitted during the first
run.
One disadvantage of this is currently StackSlotColoring is no longer
used for SGPR spills. It would need to be run again, which will
require more work.
Error if the standard -regalloc option is used. Introduce new separate
-sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be
controlled individually. PBQB is not currently supported, so this also
prevents using the unhandled allocator.
2018-09-27 01:36:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
; REGALLOC: -regalloc not supported with amdgcn. Use -sgpr-regalloc and -vgpr-regalloc
|
|
|
|
|
|
|
|
; DEFAULT: Greedy Register Allocator
|
|
|
|
; DEFAULT-NEXT: Virtual Register Rewriter
|
|
|
|
; DEFAULT-NEXT: SI lower SGPR spill instructions
|
|
|
|
; DEFAULT-NEXT: Virtual Register Map
|
|
|
|
; DEFAULT-NEXT: Live Register Matrix
|
|
|
|
; DEFAULT-NEXT: Greedy Register Allocator
|
|
|
|
; DEFAULT-NEXT: GCN NSA Reassign
|
|
|
|
; DEFAULT-NEXT: Virtual Register Rewriter
|
|
|
|
; DEFAULT-NEXT: Stack Slot Coloring
|
|
|
|
|
|
|
|
; O0: Fast Register Allocator
|
|
|
|
; O0-NEXT: SI lower SGPR spill instructions
|
|
|
|
; O0-NEXT: Fast Register Allocator
|
|
|
|
; O0-NEXT: SI Fix VGPR copies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; BASIC-DEFAULT: Debug Variable Analysis
|
|
|
|
; BASIC-DEFAULT-NEXT: Live Stack Slot Analysis
|
|
|
|
; BASIC-DEFAULT-NEXT: Machine Natural Loop Construction
|
|
|
|
; BASIC-DEFAULT-NEXT: Machine Block Frequency Analysis
|
|
|
|
; BASIC-DEFAULT-NEXT: Virtual Register Map
|
|
|
|
; BASIC-DEFAULT-NEXT: Live Register Matrix
|
|
|
|
; BASIC-DEFAULT-NEXT: Basic Register Allocator
|
|
|
|
; BASIC-DEFAULT-NEXT: Virtual Register Rewriter
|
|
|
|
; BASIC-DEFAULT-NEXT: SI lower SGPR spill instructions
|
|
|
|
; BASIC-DEFAULT-NEXT: Virtual Register Map
|
|
|
|
; BASIC-DEFAULT-NEXT: Live Register Matrix
|
|
|
|
; BASIC-DEFAULT-NEXT: Bundle Machine CFG Edges
|
|
|
|
; BASIC-DEFAULT-NEXT: Spill Code Placement Analysis
|
|
|
|
; BASIC-DEFAULT-NEXT: Lazy Machine Block Frequency Analysis
|
|
|
|
; BASIC-DEFAULT-NEXT: Machine Optimization Remark Emitter
|
|
|
|
; BASIC-DEFAULT-NEXT: Greedy Register Allocator
|
|
|
|
; BASIC-DEFAULT-NEXT: GCN NSA Reassign
|
|
|
|
; BASIC-DEFAULT-NEXT: Virtual Register Rewriter
|
|
|
|
; BASIC-DEFAULT-NEXT: Stack Slot Coloring
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; DEFAULT-BASIC: Greedy Register Allocator
|
|
|
|
; DEFAULT-BASIC-NEXT: Virtual Register Rewriter
|
|
|
|
; DEFAULT-BASIC-NEXT: SI lower SGPR spill instructions
|
|
|
|
; DEFAULT-BASIC-NEXT: Virtual Register Map
|
|
|
|
; DEFAULT-BASIC-NEXT: Live Register Matrix
|
|
|
|
; DEFAULT-BASIC-NEXT: Basic Register Allocator
|
|
|
|
; DEFAULT-BASIC-NEXT: GCN NSA Reassign
|
|
|
|
; DEFAULT-BASIC-NEXT: Virtual Register Rewriter
|
|
|
|
; DEFAULT-BASIC-NEXT: Stack Slot Coloring
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; BASIC-BASIC: Debug Variable Analysis
|
|
|
|
; BASIC-BASIC-NEXT: Live Stack Slot Analysis
|
|
|
|
; BASIC-BASIC-NEXT: Machine Natural Loop Construction
|
|
|
|
; BASIC-BASIC-NEXT: Machine Block Frequency Analysis
|
|
|
|
; BASIC-BASIC-NEXT: Virtual Register Map
|
|
|
|
; BASIC-BASIC-NEXT: Live Register Matrix
|
|
|
|
; BASIC-BASIC-NEXT: Basic Register Allocator
|
|
|
|
; BASIC-BASIC-NEXT: Virtual Register Rewriter
|
|
|
|
; BASIC-BASIC-NEXT: SI lower SGPR spill instructions
|
|
|
|
; BASIC-BASIC-NEXT: Virtual Register Map
|
|
|
|
; BASIC-BASIC-NEXT: Live Register Matrix
|
|
|
|
; BASIC-BASIC-NEXT: Basic Register Allocator
|
|
|
|
; BASIC-BASIC-NEXT: GCN NSA Reassign
|
|
|
|
; BASIC-BASIC-NEXT: Virtual Register Rewriter
|
|
|
|
; BASIC-BASIC-NEXT: Stack Slot Coloring
|
|
|
|
|
|
|
|
|
|
|
|
declare void @bar()
|
|
|
|
|
|
|
|
; Something with some CSR SGPR spills
|
|
|
|
define void @foo() {
|
|
|
|
call void asm sideeffect "; clobber", "~{s33}"()
|
|
|
|
call void @bar()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Block live out spills with fast regalloc
|
|
|
|
define amdgpu_kernel void @control_flow(i1 %cond) {
|
|
|
|
%s33 = call i32 asm sideeffect "; clobber", "={s33}"()
|
|
|
|
br i1 %cond, label %bb0, label %bb1
|
|
|
|
|
|
|
|
bb0:
|
|
|
|
call void asm sideeffect "; use %0", "s"(i32 %s33)
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
ret void
|
|
|
|
}
|