diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp @@ -100,6 +100,16 @@ void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { + if (OpNo >= MI->size()) { + // 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 instead until the necessary support + // has been implemented. + O << ""; + return; + } + const MCOperand &Op = MI->getOperand(OpNo); const MCOperandInfo &MOI = this->MII.get(MI->getOpcode()).OpInfo[OpNo]; @@ -125,6 +135,16 @@ /// being encoded as a pc-relative value. void AVRInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo, raw_ostream &O) { + if (OpNo >= MI->size()) { + // 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 instead until the necessary support + // has been implemented. + O << ""; + return; + } + const MCOperand &Op = MI->getOperand(OpNo); if (Op.isImm()) {