This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Inlining vs the stack


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Aug 12, 2005 at 02:16:39PM -0700, Ian Lance Taylor wrote:
> Mike Stump <mrs@apple.com> writes:
> > X can be run time selectable, OMF selectable, OS defined...
> 
> No.
> 
> Making the stack bigger by inlining is no different from making it
> bigger by declaring and using more local variables or calls to alloca.

void killme(void)
{
	int x[1000000000000000000]; /* Let's kill 64-bitters too. */
	int i;
	for (i = 0; i < sizeof (x) / sizeof (x[0]); i++) {
		printf("%d\n", x[i]);
	}
}

volatile int keep_going = 1;

void forever(void)
{
	while (keep_going) {
		/* Pretend this is a loop in FreeCiv. */
		ai_move_units();
		next_turn();
	}

	killme();
}

You'd expect the attempt to grow the stack to be made only *after*
keep_going hits zero.  I'd rather not have the compiler presume
certainty of a 10GB stack allocation, especially not if it's actually
pretty unlikely.

- -- 
"If you lie to the compiler, it will get its revenge." - Henry Spencer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFC/2rj/FmLrNfLpjMRAioFAJ9M/i9LXiofpXBi0pPV1SU8yk6eJgCeL/Uo
noiQWoWPZXHHHQBrriG6kd4=
=Bmte
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]