[LLVMdev] problems defining the stack layout

Chris Lattner sabre at nondot.org
Wed Aug 16 00:09:34 PDT 2006


On Tue, 15 Aug 2006, [UTF-8] Rafael Esp?ndola wrote:
> I am having some problems defining the stack layout on ARM. It should look 
> like
>
> Incoming vars
> -----------------
> Saved Link Register
> -----------------
> Local vars
> -----------------
>
> The problem is that the the first local variable is being assigned to
> the same location as the link register. I tried to use the
> OffsetOfLocalArea option, but do to alignment restrictions this
> increased the stack size.
>
> The offset of the local vars is set in calculateFrameObjectOffsets, so
> I added the following hack to eliminateFrameIndex:
>
> if (Offset < 0) //local variable
>     Offset -= 4;
>
> Is there a better way?

I'm not sure I follow the question.  It sounds like you should use the 
standard model, where local vars are allocated using variable frame 
indexes and the incoming vars are fixed frame regs.  The link register 
gets spilled to a fixed location (e.g. see the PPC backend's handling of 
the LR register).

I'm not familiar with the ARM ISA, so I don't know the right answer.  The 
OffsetOfLocalArea is used for ISAs (like X86) where the call sequence 
modifies the stack pointer (in the case of X86, the call instruction 
pushes a 4/8-byte return value).  If ARM is like PPC, where the return 
address is implicitly copied into a physreg, then you should probably use 
OffsetOfLocalArea=0 and just ask for LR to be spilled to a specific 
location (e.g. see the PPC backend).

I feel like I'm not really understanding the question though, can you 
rephrase it?

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list