[LLVMdev] MI.getNumOperands() < MI.getDesc().getNumOperands()

Edmund Grimley Evans Edmund.Grimley-Evans at arm.com
Wed Feb 3 07:55:32 PST 2010


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

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.



More information about the llvm-dev mailing list