Skip to content

Commit d21feb5

Browse files
authored
[AMDGPU] Fix crash for inline-asm inputs of type MVT::Other (#153425)
1 parent 6129e4c commit d21feb5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16894,6 +16894,11 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
1689416894

1689516895
const TargetRegisterClass *RC = nullptr;
1689616896
if (Constraint.size() == 1) {
16897+
// Check if we cannot determine the bit size of the given value type. This
16898+
// can happen, for example, in this situation where we have an empty struct
16899+
// (size 0): `call void asm "", "v"({} poison)`-
16900+
if (VT == MVT::Other)
16901+
return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
1689716902
const unsigned BitWidth = VT.getSizeInBits();
1689816903
switch (Constraint[0]) {
1689916904
default:

llvm/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ define amdgpu_kernel void @v_input_output_i8() {
1818
ret void
1919
}
2020

21+
; GCN: error: couldn't allocate input reg for constraint 'v'
22+
define amdgpu_kernel void @v_input_empty_struct() {
23+
call void asm "", "v"({} poison)
24+
ret void
25+
}
26+
2127
; SICI: error: couldn't allocate output register for constraint 's'
2228
; SICI: error: couldn't allocate input reg for constraint 's'
2329
; VI-NOT: error

0 commit comments

Comments
 (0)