[AMDGPU] Fix a crash when a bool variable is used in inline asm (#171004)

Fixes SWDEV-570184.
This commit is contained in:
Shilei Tian 2025-12-08 14:44:21 -05:00 committed by GitHub
parent b8a50c7cdb
commit 3ccd67295b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -17684,6 +17684,8 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
break;
case 'v':
switch (BitWidth) {
case 1:
return std::pair(0U, nullptr);
case 16:
RC = Subtarget->useRealTrue16Insts() ? &AMDGPU::VGPR_16RegClass
: &AMDGPU::VGPR_32_Lo256RegClass;
@ -17701,6 +17703,8 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
if (!Subtarget->hasMAIInsts())
break;
switch (BitWidth) {
case 1:
return std::pair(0U, nullptr);
case 16:
RC = &AMDGPU::AGPR_32RegClass;
break;

View File

@ -153,3 +153,27 @@ define <4 x i32> @misaligned_sgpr_4xi32_out_2() {
%asm = call <4 x i32> asm sideeffect "; def $0", "={s[2:5]}"()
ret <4 x i32> %asm
}
; ERR: error: couldn't allocate input reg for constraint 'v'
define void @i1_used_as_vgpr_operand(ptr %p, i1 %b) {
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,v"(ptr %p, i1 %b)
ret void
}
; ERR: error: couldn't allocate input reg for constraint 'a'
define void @i1_used_as_agpr_operand(ptr %p, i1 %b) {
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,a"(ptr %p, i1 %b)
ret void
}
; ERR: error: couldn't allocate input reg for constraint 's'
define void @i1_used_as_sgpr_operand_s(ptr %p, i1 %b) {
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,s"(ptr %p, i1 %b)
ret void
}
; ERR: error: couldn't allocate input reg for constraint 'r'
define void @i1_used_as_sgpr_operand_r(ptr %p, i1 %b) {
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,r"(ptr %p, i1 %b)
ret void
}