Skip to content

Commit f0b36a3

Browse files
committed
The tLDR instruction wasn't encoded properly:
<MCInst 2251 <MCOperand Reg:70> <MCOperand Reg:66> <MCOperand Imm:0> <MCOperand Reg:0> <MCOperand Imm:14> <MCOperand Reg:0>> Notice that the "reg" here is 0, which is an invalid register. Put a check in the code for this to prevent crashing. llvm-svn: 120766
1 parent 518a6e6 commit f0b36a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,12 @@ static unsigned getAddrModeSOpValue(const MCInst &MI, unsigned OpIdx,
642642
const MCOperand &MO2 = MI.getOperand(OpIdx + 2);
643643
unsigned Rn = getARMRegisterNumbering(MO.getReg());
644644
unsigned Imm5 = (MO1.getImm() / Scale) & 0x1f;
645-
unsigned Rm = getARMRegisterNumbering(MO2.getReg());
646-
return (Rm << 3) | (Imm5 << 3) | Rn;
645+
646+
if (MO2.getReg() != 0)
647+
// Is an immediate.
648+
Imm5 = getARMRegisterNumbering(MO2.getReg());
649+
650+
return (Imm5 << 3) | Rn;
647651
}
648652

649653
/// getAddrModeS4OpValue - Return encoding for t_addrmode_s4 operands.

0 commit comments

Comments
 (0)