This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/9624] Stack space allocation too gratuitious
- From: "bisqwit at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2004 11:29:54 -0000
- Subject: [Bug rtl-optimization/9624] Stack space allocation too gratuitious
- References: <20030208002600.9624.dath@ficker.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bisqwit at iki dot fi 2004-09-08 11:29 -------
Alignment indeed rounds up the size, but consider this code:
void xxx(void)
{
unsigned x[12451];
}
No matter which optimization settings you run it at (even with
-fomit-frame-pointer), gcc will still emit code that allocates 49804+ bytes from
stack and immediately releases it. On x86, for example, it does this:
_Z3xxxv:
subl $49820, %esp
addl $49820, %esp
ret
Same thing also happens for unused local structs and classes.
The stack space isn't freed.
This does not happen with simple variables (ints and such), probably because the
compiler treats them as register variables by default and only allocates stack
space when it has no other choice.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9624