Skip to content

Commit f6365a4

Browse files
authored
AMDGPU: Fix assert on physreg MUBUF rsrc operand (#120815)
The stack case uses a physical register and should not ordinarily reach here, but strange things happen at -O0. The testcase still errors because we do not yet attempt to handle arbitrary dynamic sized allocas yet. Fixes: SWDEV-503538
1 parent 7e2ed35 commit f6365a4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6890,9 +6890,8 @@ SIInstrInfo::legalizeOperands(MachineInstr &MI,
68906890
AMDGPU::getNamedOperandIdx(MI.getOpcode(), AMDGPU::OpName::srsrc);
68916891
if (RsrcIdx != -1) {
68926892
MachineOperand *Rsrc = &MI.getOperand(RsrcIdx);
6893-
if (Rsrc->isReg() && !RI.isSGPRClass(MRI.getRegClass(Rsrc->getReg()))) {
6893+
if (Rsrc->isReg() && !RI.isSGPRReg(MRI, Rsrc->getReg()))
68946894
isRsrcLegal = false;
6895-
}
68966895
}
68976896

68986897
// The operands are legal.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: not llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -O0 2> %t.err < %s | FileCheck %s
2+
; RUN: FileCheck -check-prefix=ERR %s < %t.err
3+
4+
; FIXME: This error will be fixed by supporting arbitrary divergent
5+
; dynamic allocas by performing a wave umax of the size.
6+
7+
; ERR: error: <unknown>:0:0: in function move_to_valu_assert_srd_is_physreg_swdev503538 i32 (ptr addrspace(1)): illegal VGPR to SGPR copy
8+
9+
; CHECK: ; illegal copy v0 to s32
10+
11+
define i32 @move_to_valu_assert_srd_is_physreg_swdev503538(ptr addrspace(1) %ptr) {
12+
entry:
13+
%idx = load i32, ptr addrspace(1) %ptr, align 4
14+
%zero = extractelement <4 x i32> zeroinitializer, i32 %idx
15+
%alloca = alloca [2048 x i8], i32 %zero, align 8, addrspace(5)
16+
%ld = load i32, ptr addrspace(5) %alloca, align 8
17+
call void @llvm.memset.p5.i32(ptr addrspace(5) %alloca, i8 0, i32 2048, i1 false)
18+
ret i32 %ld
19+
}
20+
21+
declare void @llvm.memset.p5.i32(ptr addrspace(5) nocapture writeonly, i8, i32, i1 immarg) #0
22+
23+
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }

0 commit comments

Comments
 (0)