[LLVMdev] Register Allocation problem

John Cortes jcortes at cs.ucr.edu
Mon May 16 17:15:30 PDT 2005


Ok, i'm having a problem with understanding the allocating of registers. 
  I've written in the "addPassesToEmitAssembly()" the passes to create 
the assembly code, as in the PowerPC example.  I'ved tried filling up as 
much of the code in <Target>RegisterInfo.cpp (Register/Frame code) to 
handle writing and reading from stack.


The allocation method I used was -regalloc=simple, so it only wrote to 2 
or 3 registers total, with a lot of loading and writing to stack.

If I use any of the regalloc parameters (local, ...) I get an error in 
the LiveVariable.cpp file, in the part that I think cheaks for dead code 
because a Variable didn't have a defined Instance to a Machine instruction.

"
llc: LiveVariables.cpp:86: void 
llvm::LiveVariables::HandleVirtRegUse(llvm::LiveVariables::VarInfo&, 
llvm::MachineBasicBlock*, llvm::MachineInstr*): Assertion 
`VRInfo.DefInst && "Register use before def!"' failed.
/home/llvm/Debug/bin/llc((anonymous 
namespace)::PrintStackTrace()+0x1a)[0x86abeda]
/home/llvm/Debug/bin/llc((anonymous 
namespace)::SignalHandler(int)+0xcb)[0x86ac14d]
...
"

Is there any passes that need to occur to correct this error?  For the 
passes in emitting assembly I have this:

" PM.add(createLowerGCPass());

   PM.add(createLowerInvokePass());

   PM.add(createLowerSwitchPass());

   PM.add(createUnreachableBlockEliminationPass());
   PM.add(create<MYTARGET>ISelSimple(*this));

   if(PrintMachineCode)
           PM.add(createMachineFunctionPrinterPass(&std::cerr));


   PM.add(createRegisterAllocator());
   if(PrintMachineCode)
           PM.add(createMachineFunctionPrinterPass(&std::cerr));

   PM.add(createPrologEpilogCodeInserter());

   PM.add(create<MYTARGET>AsmPrinter(Out, *this));

   PM.add(createMachineCodeDeleter());
"
The backend target I'm writing is to a subset of MIPS32, so I borrowed 
some amount of code from PowerPC.


Thanks for any help.




More information about the llvm-dev mailing list