Re: GCC stack size
Re: GCC stack size
- Subject: Re: GCC stack size
- From: Ryan McGann <email@hidden>
- Date: Thu, 05 Mar 2009 10:09:28 -0800
On Mar 3, 2009, at 2:00 PM, Brian Mastenbrook wrote:
On Mar 3, 2009, at 3:35 PM, Ryan McGann wrote:
We have some sample code that shows that the temporary returned
from the function doMath is allocated stack space twice, when it
can only be used once. But since the function in our actual
production code is pretty complex, it's hard to know hwich problem
we are experiencing.
However, the above examples are both well documented cases of GCC
problems; I actually got the basic ideas for both examples from
Linus Torvald's (sometimes long) emails regarding Linux's problems
with GCC stack allocation.
I've been bitten by this problem in the past as well, especially in
functions that look a lot like the examples you've given (where an
outer if wraps several complex code blocks). The worst of it is that
in this example:
void foo(int flag)
{
if (flag) {
largeStackUsingFunction();
} else {
char buf[1000];
/* ... other code which does not call functions ... */
}
}
Just to let everybody know, I got the library to compile with the
Intel icc compiler. It produced a stack in debug builds (-O0) that is
116 bytes, and in release builds (-O3) is 92 bytes. Obviously this is
perfect for our x86/x86_64 builds. Our PowerPC customers are
unfortunately hosed, as the IBM compiler does not look like it will
work in the time that I have to finish this project. For PowerPC we
will unfortunately lose some major features, but at least it won't
panic.
Thanks to all for the help.
Ryan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden