[PATCH] D73958: [AVR] Don't assert on an undefined operand

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 05:37:45 PST 2020


aykevl created this revision.
aykevl added a reviewer: dylanmckay.
Herald added subscribers: llvm-commits, Jim, hiraditya.
Herald added a project: LLVM.

Not all operands are correctly disassembled at the moment. This means that some machine instructions won't have all the necessary operands set.

To avoid asserting, print an error instead until the necessary support has been implemented.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73958

Files:
  llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp


Index: llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
===================================================================
--- llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
+++ llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp
@@ -100,6 +100,11 @@
 
 void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                   raw_ostream &O) {
+  if (OpNo >= MI->size()) {
+    O << "<unknown>";
+    return;
+  }
+
   const MCOperand &Op = MI->getOperand(OpNo);
   const MCOperandInfo &MOI = this->MII.get(MI->getOpcode()).OpInfo[OpNo];
 
@@ -125,6 +130,11 @@
 /// being encoded as a pc-relative value.
 void AVRInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
                                    raw_ostream &O) {
+  if (OpNo >= MI->size()) {
+    O << "<unknown>";
+    return;
+  }
+
   const MCOperand &Op = MI->getOperand(OpNo);
 
   if (Op.isImm()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73958.242305.patch
Type: text/x-patch
Size: 908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200204/b29f7010/attachment.bin>


More information about the llvm-commits mailing list