Skip to content

Commit

Permalink
[AVR] Fix a bug in AsmPrinter when printing inline-asm operands
Browse files Browse the repository at this point in the history
Fixes #58878

Reviewed By: aykevl, Miss_Grape

Differential Revision: https://reviews.llvm.org/D141589
  • Loading branch information
benshi001 committed Jan 13, 2023
1 parent 3e19888 commit 159e2a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/AVR/AVRAsmPrinter.cpp
Expand Up @@ -128,8 +128,8 @@ bool AVRAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
assert(BytesPerReg <= 2 && "Only 8 and 16 bit regs are supported.");

unsigned RegIdx = ByteNumber / BytesPerReg;
assert(RegIdx < NumOpRegs && "Multibyte index out of range.");

if (RegIdx >= NumOpRegs)
return true;
Reg = MI->getOperand(OpNum + RegIdx).getReg();

if (BytesPerReg == 2) {
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
Expand Up @@ -8,3 +8,8 @@ define void @foo(i16 %a) {
ret void
}

define void @foo1() {
; CHECK: error: invalid operand in inline asm: ';; ${0:C}'
call i16 asm sideeffect ";; ${0:C}", "=d"()
ret void
}

0 comments on commit 159e2a8

Please sign in to comment.