[LLVMdev] Spilling register and frame indices

Evan Cheng evan.cheng at apple.com
Tue May 23 10:43:50 PDT 2006


Yeah, a iterative approach, i.e. while (...) { RegisterAllocate();  
InsertSpills(); } should work well for your target (and others!).  
Feel free to contribute. :-)

storeRegToStackSlot is also called from VirtRegMap.cpp which does  
some of spilling / restoring work.

Evan

On May 23, 2006, at 6:33 AM, Vladimir Prus wrote:

>
> Hi,
> right now, LLVM does register spilling by:
>
> 1. Creating stack object
> 2. Passing index of that stack object to  
> MRegisterInfo::storeRegToStackSlot
> 3. At later stage, frame indices are replaced by calling to
> MRegisterInfo::eliminateFrameIndex.
>
> This works for me, but there's slight problem. The target does not  
> have
> "register + contant" addressing mode, so accessing frame index  
> should be
> done like this:
>
>    some_register = frame_pointer + offset
>          ...... [some_register]
>
> Since frame index eliminations happens after register allocation, I  
> must
> make sure 'some_register' does not participate in normal register
> allocation.
>
> That approach sounds suboptimal. By "reserving" one register we can  
> already
> cause some values to be spilled, that otherwise would be stored in
> register.
>
> The lifetimes of those 'some_register' is likely to be very small (1
> instruction), so "reserving" it everywhere is not good.
>
> Ideal approach would be to add a method to MRegisterInfo to spill  
> specific
> virtual register. The implementation can then create code like:
>
>    virtual_register = frame_pointer + offset
>          [virtual_register]
>
> and then have 'virtual_register' allocated on next iteration of  
> register
> allocator?
>
> Also, while RegAllocLocal and RegAllocSimple directly call
> storeRegToStackSlot, I would not found any calls to that method in
> RegAllocLinearScan. Am I missing something?
>
> - Volodya
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list