[LLVMdev] Register allocator segfault

Alkis Evlogimenos alkis at cs.uiuc.edu
Wed Sep 1 15:35:59 PDT 2004


On Wed, 2004-09-01 at 08:37, Vladimir Prus wrote:
> Hello,
> this is another "allocator crashes hard when I pass wrong data to it" issue. 
> Due to a bug, my machine code looked like this:
> 
> # Machine code for list_sequence():
>   <fi #-2> is 4 bytes fixed at location [SP-24]
>   <fi #-1> is 4 bytes fixed at location [SP-20]
> 
> entry (0x8060970, LLVM BB @0x805da88):
>         %reg1024 = load <fi#-1>
>         %reg1025 = load <fi#-2>
>         setcc %reg1025, %reg1026
> 
> (so 'reg1026' is used before definition). It would be nice if register 
> allocator responded with a nice 'register used before definition in 
> instruction ....' message. What I get now is:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x400c24d4 in llvm::MachineInstr::getParent (this=0x0)
>     at MachineInstr.h:408
> 408     MachineInstr.h: No such file or directory.
>         in MachineInstr.h
> (gdb) up
> #1  0x40f05f28 in llvm::LiveVariables::HandleVirtRegUse (
>     this=0x8060270, VRInfo=@0x8061930, MBB=0x8060970, MI=0x80615d0)
>     at ../../lib/CodeGen/LiveVariables.cpp:100
> 100       assert(MBB != VRInfo.DefInst->getParent() &&
> (gdb) p VRInfo.DefInst
> $1 = (llvm::MachineInstr *) 0x0
> (gdb) up
> #2  0x40f0678f in llvm::LiveVariables::runOnMachineFunction (
>     this=0x8060270, MF=@0x8060888)
>     at ../../lib/CodeGen/LiveVariables.cpp:214
> 214                 HandleVirtRegUse(getVarInfo(MO.getReg()), MBB, MI);
> (gdb) p MO.getReg()
> $3 = 1026
> 
> Of course, this is just a wish, and it looks like it's exactly what issue 408
> (http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=408) is about.

I have commited a patch that would give a better assertion:

http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040830/017768.html

-- 

Alkis




More information about the llvm-dev mailing list