From c761675ef467f4b76728a1b2e726f0a558c00630 Mon Sep 17 00:00:00 2001 From: Valery Pykhtin Date: Mon, 15 Aug 2016 10:56:48 +0000 Subject: [PATCH] [AMDGPU] fix failure on printing of non-existing instruction operands. Differential revision: https://reviews.llvm.org/D23323 llvm-svn: 278665 --- llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp | 5 +++++ llvm/test/MC/Disassembler/AMDGPU/missing_op.txt | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 llvm/test/MC/Disassembler/AMDGPU/missing_op.txt diff --git a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp index 2932d3bb1580..7dd0f009533a 100644 --- a/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp @@ -370,6 +370,11 @@ void AMDGPUInstPrinter::printImmediate64(uint64_t Imm, raw_ostream &O) { void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { + if (OpNo >= MI->getNumOperands()) { + O << "/*Missing OP" << OpNo << "*/"; + return; + } + const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { switch (Op.getReg()) { diff --git a/llvm/test/MC/Disassembler/AMDGPU/missing_op.txt b/llvm/test/MC/Disassembler/AMDGPU/missing_op.txt new file mode 100644 index 000000000000..7c4e252fde4b --- /dev/null +++ b/llvm/test/MC/Disassembler/AMDGPU/missing_op.txt @@ -0,0 +1,5 @@ +# RUN: llvm-mc -arch=amdgcn -mcpu=fiji -disassemble < %s | FileCheck %s -check-prefix=VI + +#TODO: this test will fail when we fix v_interp_p2_f32 signature, remove it then +#VI: v_interp_p2_f32 16, [/*Missing OP1*/], /*Missing OP2*/, /*Missing OP3*/, /*Missing OP4*/ +0xd4 0x41 0x1d 0xd4