This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: extra space on stack allocated for recursive functions
- From: "Rupert Wood" <me at rupey dot net>
- To: "'Chris Meyer'" <chrisemeyer at yahoo dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 24 Oct 2003 11:33:57 +0100
- Subject: RE: extra space on stack allocated for recursive functions
Chris Meyer wrote:
> I noticed that when I call a recursive function there is extra space
> allocated on the stack.
You mean this subl, say?
> subl $12, %esp
> pushl $3
> call factorial
It's keeping the stack pointer 16-byte aligned. If you passed two arguments
it would have subled $8 first, etc. This isn't unique to recursive
functions.
Why? It's probably so you can get all the arguments in a single L1 cache
load or something. I'd guess it's in the Intel's optimisation guide,
downloadable as part of the architecture docs.
Rup.