Index: llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp =================================================================== --- llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp +++ llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp @@ -2676,8 +2676,12 @@ if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<26>(imm) + 8, true, 4, Inst, Decoder)) Inst.addOperand(MCOperand::createImm(SignExtend32<26>(imm))); - if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder))) - return MCDisassembler::Fail; + + // We already have BL_pred for BL w/ predicate, no need to add addition + // predicate opreands for BL + if (Inst.getOpcode() != ARM::BL) + if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder))) + return MCDisassembler::Fail; return S; } @@ -6670,17 +6674,14 @@ return MCDisassembler::Fail; if (TypeT3) { Inst.setOpcode(sign1 ? ARM::t2SUBspImm12 : ARM::t2ADDspImm12); - S = 0; Inst.addOperand(MCOperand::createImm(Imm12)); // zext imm12 } else { Inst.setOpcode(sign1 ? ARM::t2SUBspImm : ARM::t2ADDspImm); if (!Check(DS, DecodeT2SOImm(Inst, Imm12, Address, Decoder))) // imm12 return MCDisassembler::Fail; + if (!Check(DS, DecodeCCOutOperand(Inst, S, Address, Decoder))) // cc_out + return MCDisassembler::Fail; } - if (!Check(DS, DecodeCCOutOperand(Inst, S, Address, Decoder))) // cc_out - return MCDisassembler::Fail; - - Inst.addOperand(MCOperand::createReg(0)); // pred return DS; } Index: llvm/test/MC/Disassembler/ARM/bug49974.arm.txt =================================================================== --- /dev/null +++ llvm/test/MC/Disassembler/ARM/bug49974.arm.txt @@ -0,0 +1,11 @@ +# RUN: llvm-mc -triple=arm -disassemble -show-inst < %s | FileCheck %s + +# https://bugs.llvm.org/show_bug.cgi?id=49974 +# Redundant (predicate) operands were inserted to the +# disassembled MCInst. + +# CHECK: bl #152 +# CHECK-SAME: > + +0x26 0x00 0x00 0xeb Index: llvm/test/MC/Disassembler/ARM/bug49974.thumb2.txt =================================================================== --- /dev/null +++ llvm/test/MC/Disassembler/ARM/bug49974.thumb2.txt @@ -0,0 +1,15 @@ +# RUN: llvm-mc -triple=thumbv7 -disassemble -show-inst < %s | FileCheck %s + +# https://bugs.llvm.org/show_bug.cgi?id=49974 +# Incorrect number of predicate operands were inserted to the +# disassembled MCInst. + +# CHECK: subw sp, sp, #1148 +# CHECK-SAME: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: > + +0xad 0xf2 0x7c 0x4d