Skip to content

[AMDGPU] Fix crash for inline-asm inputs of type MVT::Other #153425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16894,6 +16894,11 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,

const TargetRegisterClass *RC = nullptr;
if (Constraint.size() == 1) {
// Check if we cannot determine the bit size of the given value type. This
// can happen, for example, in this situation where we have an empty struct
// (size 0): `call void asm "", "v"({} poison)`-
if (VT == MVT::Other)
return TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
const unsigned BitWidth = VT.getSizeInBits();
switch (Constraint[0]) {
default:
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/CodeGen/AMDGPU/inlineasm-illegal-type.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ define amdgpu_kernel void @v_input_output_i8() {
ret void
}

; GCN: error: couldn't allocate input reg for constraint 'v'
define amdgpu_kernel void @v_input_empty_struct() {
call void asm "", "v"({} poison)
ret void
}

; SICI: error: couldn't allocate output register for constraint 's'
; SICI: error: couldn't allocate input reg for constraint 's'
; VI-NOT: error
Expand Down