Skip to content

Commit 09f4492

Browse files
authored
[RISCV] Check for register where immediate should be in RISCVInstrInfo::verifyInstruction. (#120286)
The generic verifier will do this if the operand type is OPERAND_IMMEDIATE, but we use our own custom operand types. Immediate operands are still allowed to be globals, constant pools, blockaddress, etc. so we can't check !isImm().
1 parent c03fc92 commit 09f4492

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,10 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
24512451
if (OpType >= RISCVOp::OPERAND_FIRST_RISCV_IMM &&
24522452
OpType <= RISCVOp::OPERAND_LAST_RISCV_IMM) {
24532453
const MachineOperand &MO = MI.getOperand(Index);
2454+
if (MO.isReg()) {
2455+
ErrInfo = "Expected a non-register operand.";
2456+
return false;
2457+
}
24542458
if (MO.isImm()) {
24552459
int64_t Imm = MO.getImm();
24562460
bool Ok;

0 commit comments

Comments
 (0)