[Bug rtl-optimization/9624] Stack space allocation too gratuitious

bisqwit at iki dot fi gcc-bugzilla@gcc.gnu.org
Wed Sep 8 11:29:00 GMT 2004


------- 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



More information about the Gcc-bugs mailing list