[LLVMdev] Register allocator assert

Vladimir Prus ghost at cs.msu.su
Fri Aug 27 06:05:49 PDT 2004


Hello, 
I'm getting an assertion in register allocator, specifically in 
LiveIntervalAnalysis.h, method LiveIntervals::getInstructionIndex:

 unsigned getInstructionIndex(MachineInstr* instr) const {
      Mi2IndexMap::const_iterator it = mi2iMap_.find(instr);
      assert(it != mi2iMap_.end() && "Invalid instruction!");
      return it->second;
    }

The crash happens when the function is called from LiveIntervalAnalysis.cpp, 
360:

  for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
      MachineInstr *Kill = vi.Kills[i];
      LiveRange LR(getInstructionIndex(Kill->getParent()->begin()),
                   getUseIndex(getInstructionIndex(Kill))+1, ValNum);
      interval.addRange(LR);
      DEBUG(std::cerr << " +" << LR);

When I add

      assert(mi2iMap_.count(Kill));

in that block, it fires. I have modified the LiveVariables class so that in 
the end of runOnFunction method, it prints all the instructions which are in 
Kill sets, but are not in the original functions. (Presumably, those are 
spill instructions). Here's what I get:

Extra instruction 0x8061318
Extra instruction 0x80613d8
Extra instruction 0x8061218
Extra instruction 0x8061418

Program received signal SIGABRT, Aborted.
.......
    at ../../lib/CodeGen/LiveIntervalAnalysis.cpp:354
354           assert(mi2iMap_.count(Kill));
(gdb) p Kill
$1 = (llvm::MachineInstr *) 0x8061318

So, mi2iMap_ seems to be indexes with an address of a spill instruction, which 
is not present in that map. I see that the map is originally initialized with 
instructions in function and then only modified at 
LiveIntervalAnalysis.cpp:219, but that code is only executed when 
MRegisterInfo::foldMemoryOperand returns something, and I did not define that 
method for my backend.

Any ideas how I can debug this? I attach the dumps of machine code which cause 
the problems, but I'm afraid that won't be enough to reproduce the problem.

Thanks in advance,
Volodya



-------------- next part --------------
A non-text attachment was scrubbed...
Name: log.llc
Type: text/x-csrc
Size: 9729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20040827/719b2d09/attachment.c>


More information about the llvm-dev mailing list