[llvm] 159e2a8 - [AVR] Fix a bug in AsmPrinter when printing inline-asm operands
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 12 22:23:59 PST 2023
Author: Ben Shi
Date: 2023-01-13T14:23:41+08:00
New Revision: 159e2a804d908edc92966f0485881eb78778c92d
URL: https://github.com/llvm/llvm-project/commit/159e2a804d908edc92966f0485881eb78778c92d
DIFF: https://github.com/llvm/llvm-project/commit/159e2a804d908edc92966f0485881eb78778c92d.diff
LOG: [AVR] Fix a bug in AsmPrinter when printing inline-asm operands
Fixes https://github.com/llvm/llvm-project/issues/58878
Reviewed By: aykevl, Miss_Grape
Differential Revision: https://reviews.llvm.org/D141589
Added:
Modified:
llvm/lib/Target/AVR/AVRAsmPrinter.cpp
llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
index 897a45e9df4c7..61f39c595253e 100644
--- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -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) {
diff --git a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
index 8a3dcfc90ab84..98b0709fcc3e0 100644
--- a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
+++ b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
@@ -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
+}
More information about the llvm-commits
mailing list