MI.getNumOperands() < MI.getDesc().getNumOperands()

With a modified copy of LLVM (so it's probably my fault) I'm getting
an assertion failure because isTwoAddrUse (in
TwoAddressInstructionPass.cpp) is being called with a MachineInstr MI
such that MI.getNumOperands() is 2, but MI.getDesc().getNumOperands()
is 5. The assertion fails when that function calls MI.getOperand(2).

My question is: is isTwoAddrUse doing the right thing here?

static bool isTwoAddrUse(MachineInstr &MI, unsigned Reg, unsigned
&DstReg) {
  const TargetInstrDesc &TID = MI.getDesc();
  unsigned NumOps = (MI.getOpcode() == TargetInstrInfo::INLINEASM)
    ? MI.getNumOperands() : TID.getNumOperands();
  for (unsigned i = 0; i != NumOps; ++i) {
    const MachineOperand &MO = MI.getOperand(i);
    ...

This code seems to be written with the assumption that
MI.getDesc().getNumOperands() <= MI.getNumOperands() ||
MI.getOpcode() == TargetInstrInfo::INLINEASM

Why does your instruction only have 2 operands when the description says it should have 5? That should never happen except when first building the instruction.