Problem with isMoveInstr

I've tried to implement the isMoveInstr method from TargetInstrInfo class, and
the register allocator immediately started to crash, in:

#4 0x40e88787 in llvm::LiveIntervals::joinIntervals (this=0x80630b0)
    at ../lib/CodeGen/LiveIntervals.cpp:493
493 assert(r2iA != r2iMap_.end());

The instruction it crashes is:

(gdb) p $4.dump()
  %reg1056 = move %gr7

And gr7 is exactly the register which is looked up with

   Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA)

on line 492. I'm not sure the about the logic, but seems the code tries to map
register into live interval, and since the above gr7 is inserted by code
selector (it's return value from a function), it's not wonder no interval is
found.

I've worked this around by making isMoveInstr return false when either of
operands is physical register, but looks like this defeats the purpose of
isMoveInstr. What kind of information I can further provide to help diagnose
the problem?

Thanks,
Volodya

I've tried to implement the isMoveInstr method from TargetInstrInfo class, and
the register allocator immediately started to crash, in:

#4 0x40e88787 in llvm::LiveIntervals::joinIntervals (this=0x80630b0)
    at ../lib/CodeGen/LiveIntervals.cpp:493
493 assert(r2iA != r2iMap_.end());

The instruction it crashes is:

(gdb) p $4.dump()
  %reg1056 = move %gr7

And gr7 is exactly the register which is looked up with

   Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA)

on line 492. I'm not sure the about the logic, but seems the code tries to map
register into live interval, and since the above gr7 is inserted by code
selector (it's return value from a function), it's not wonder no interval is
found.

You are right that it looks for the intervals for the register. But,
there should be an interval for gr7 as well. Is it defined somewhere
before that? Can you show some of the code before the use if gr7?

I've worked this around by making isMoveInstr return false when either of
operands is physical register, but looks like this defeats the purpose of
isMoveInstr. What kind of information I can further provide to help diagnose
the problem?

Make sure gr7 is defined somewhere in the basic block the move belongs
to. If you still see the crash it would be nice to see the interval for
gr7 and the debug output of regalloc using -debug-only=regalloc.

One other important point: physical registers are only allowed to be live
inside of a basic block before register allocation occurs. If you have a
value that lives across an MBB, it has to be a virtual register.

-Chris