Skip to content

Commit 5037c8f

Browse files
shiltianHoney Goyal
authored andcommitted
[AMDGPU] Fix a crash when a bool variable is used in inline asm (llvm#171004)
Fixes SWDEV-570184.
1 parent 6303b69 commit 5037c8f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17684,6 +17684,8 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
1768417684
break;
1768517685
case 'v':
1768617686
switch (BitWidth) {
17687+
case 1:
17688+
return std::pair(0U, nullptr);
1768717689
case 16:
1768817690
RC = Subtarget->useRealTrue16Insts() ? &AMDGPU::VGPR_16RegClass
1768917691
: &AMDGPU::VGPR_32_Lo256RegClass;
@@ -17701,6 +17703,8 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
1770117703
if (!Subtarget->hasMAIInsts())
1770217704
break;
1770317705
switch (BitWidth) {
17706+
case 1:
17707+
return std::pair(0U, nullptr);
1770417708
case 16:
1770517709
RC = &AMDGPU::AGPR_32RegClass;
1770617710
break;

llvm/test/CodeGen/AMDGPU/inlineasm-mismatched-size-error.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,27 @@ define <4 x i32> @misaligned_sgpr_4xi32_out_2() {
153153
%asm = call <4 x i32> asm sideeffect "; def $0", "={s[2:5]}"()
154154
ret <4 x i32> %asm
155155
}
156+
157+
; ERR: error: couldn't allocate input reg for constraint 'v'
158+
define void @i1_used_as_vgpr_operand(ptr %p, i1 %b) {
159+
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,v"(ptr %p, i1 %b)
160+
ret void
161+
}
162+
163+
; ERR: error: couldn't allocate input reg for constraint 'a'
164+
define void @i1_used_as_agpr_operand(ptr %p, i1 %b) {
165+
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,a"(ptr %p, i1 %b)
166+
ret void
167+
}
168+
169+
; ERR: error: couldn't allocate input reg for constraint 's'
170+
define void @i1_used_as_sgpr_operand_s(ptr %p, i1 %b) {
171+
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,s"(ptr %p, i1 %b)
172+
ret void
173+
}
174+
175+
; ERR: error: couldn't allocate input reg for constraint 'r'
176+
define void @i1_used_as_sgpr_operand_r(ptr %p, i1 %b) {
177+
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,r"(ptr %p, i1 %b)
178+
ret void
179+
}

0 commit comments

Comments
 (0)