Skip to content

Commit

Permalink
Fixed the arm disassembly of invalid BFI instructions to not build a …
Browse files Browse the repository at this point in the history
…bad MCInst

which would then cause an assert when printed.  rdar://11437956


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168960 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
enderby committed Nov 29, 2012
1 parent 5cf823c commit 1c83093
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Target/ARM/Disassembler/ARMDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,13 @@ static DecodeStatus DecodeBitfieldMaskOperand(MCInst &Inst, unsigned Val,
unsigned lsb = fieldFromInstruction(Val, 0, 5);

DecodeStatus S = MCDisassembler::Success;
if (lsb > msb) Check(S, MCDisassembler::SoftFail);
if (lsb > msb) {
Check(S, MCDisassembler::SoftFail);
// The check above will cause the warning for the "potentially undefined
// instruction encoding" but we can't build a bad MCOperand value here
// with a lsb > msb or else printing the MCInst will cause a crash.
lsb = msb;
}

uint32_t msb_mask = 0xFFFFFFFF;
if (msb != 31) msb_mask = (1U << (msb+1)) - 1;
Expand Down
11 changes: 11 additions & 0 deletions test/MC/Disassembler/ARM/unpredictable-BFI.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 2>&1 | FileCheck %s

# rdar://11437956

# CHECK: warning: invalid instruction encoding
# CHECK: 0x90 0x00 0xc0 0xe7
0x90 0x00 0xc0 0xe7

# CHECK: warning: invalid instruction encoding
# CHECK: 0x90 0x01 0xc0 0xe7
0x90 0x01 0xc0 0xe7

0 comments on commit 1c83093

Please sign in to comment.