[LLVMdev] Stack alignment in leaf functions

Vladimir Prus ghost at cs.msu.su
Tue May 16 05:42:52 PDT 2006


Hi,
right at the moment, LLVM won't align the stack for leaf functions. So, if
stack alignment is 8 bytes, and leaf function has 1 variable of 4 bytes,
the size of frame will be computed as 4 bytes, making stack pointer inside
function non-aligned.

I've mentioned this before:

   http://lists.cs.uiuc.edu/pipermail/llvmdev/2005-March/003701.html

but did not pursue the issue back then.

For my target, the stack should be aligned even for leaf functions. In
particular, hardware interrupt can arrive at any time, and stack should be
8-byte aligned at the time of interrupt, otherwise things will break.

I can address this issue by using two tricks together:

1. Calling MachineFrameInfo::setHasCalls in my backend
2. Using the attached patch, so that value of setHasCalls is not reset to
false later.

Comments? 

BTW, I've checked other uses of MachineFrameInfo::hasCalls. For example,
PPCRegisterInfo uses it to check if if callee save registers can be stored
in something called "red zone", whatever that is.

I wonder how this relates to interrupts. Say, function X is running.
Interrupt arrives, and the interrupt handlers calls function X again. So, if
that "red zone" is some static memory area, the values there are
overwritten. Am I missing something? Should there be some "interrupts safe"
mode?



- Volodya
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PrologEpilogInserter.diff
Type: text/x-diff
Size: 812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060516/4997ae84/attachment.diff>


More information about the llvm-dev mailing list