[llvm-commits] [LLVMdev] Spilled variables using unaligned moves

Evan Cheng evan.cheng at apple.com
Wed Jul 16 00:01:49 PDT 2008


Ok. The issue is in X86InstrInfo.cpp:

void X86InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
                                             
MachineBasicBlock::iterator MI,
                                            unsigned DestReg, int  
FrameIdx,
                                            const TargetRegisterClass  
*RC) const{
   unsigned Opc = getLoadRegOpcode(RC, RI.getStackAlignment());
   addFrameReference(BuildMI(MBB, MI, get(Opc), DestReg), FrameIdx);
}

static unsigned getLoadRegOpcode(const TargetRegisterClass *RC,
                                  unsigned StackAlign) {
...
   } else if (RC == &X86::VR128RegClass) {
     // FIXME: Use movaps once we are capable of selectively
     // aligning functions that spill SSE registers on 16-byte  
boundaries.
     Opc = StackAlign >= 16 ? X86::MOVAPSrm : X86::MOVUPSrm;
...
}

So we just need to teach it to use MOVAPSrm if stack ptr is going to  
be realigned. Anton, I am not familiar with the realignment code. But  
is it now always safe to spill with MOVAPSrm since stack ptr is always  
realigned? Is it done for all subtargets?

Evan

On Jul 14, 2008, at 11:46 AM, Anton Korobeynikov wrote:

> Hello, Evan
>
>> This is on Windows / Cygwin? I think the dynamic stack pointer re- 
>> alignment doesn't happen until post- register allocation.
> Actually it's split into two parts. One is just small hook at pre-RA  
> level, which determines, whether stack realignment is really needed,  
> and if yes - "reserves" it during RA.
>
> The biggest part runs indeed at post-RA phase, but it just realigns  
> stack and translates 'virtual offsets' into real ones. For aligned  
> variables virtual offsets should be already aligned at this stage.
>
> ----
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State  
> University
>




More information about the llvm-commits mailing list