Skip to content

Commit 28518f9

Browse files
authored
[AMDGPU] Fix crash for inline-asm inputs of type MVT::Other (#153401)
1 parent 4800a5f commit 28518f9

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
@@ -16476,6 +16476,11 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
1647616476

1647716477
const TargetRegisterClass *RC = nullptr;
1647816478
if (Constraint.size() == 1) {
16479+
// Check if we cannot determine the bit size of the given value type. This
16480+
// can happen, for example, in this situation where we have an empty struct
16481+
// (size 0): `call void asm "", "v"({} poison)`-
16482+
if (VT == MVT::Other)
16483+
return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
1647916484
const unsigned BitWidth = VT.getSizeInBits();
1648016485
switch (Constraint[0]) {
1648116486
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)