This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Status of -fstack-usage?
- From: Olivier Hainque <hainque at adacore dot com>
- To: "Ioannis E. Venetis" <iev at hpclab dot ceid dot upatras dot gr>
- Cc: gcc at gcc dot gnu dot org, hainque at adacore dot com
- Date: Thu, 19 Jan 2006 18:34:26 +0100
- Subject: Re: Status of -fstack-usage?
- References: <43CE3678.1000802@hpclab.ceid.upatras.gr>
Hello,
Ioannis E. Venetis wrote:
> Having followed this thread and searched a little bit more, I understand
> that -fstack-usage will dump information into a file at compile time.
Right.
> However, I was wondering whether something similar would be possible at
> run-time.
>
> I am working on multithreaded libraries and I know that many
> multithreaded languages have compilers that calculate the required stack
> size and pass this information on to the associated library. This way,
> they can handle efficiently memory. However, this is a problem in
> standalone libraries. If we could have something like:
>
> stack_size = __builtin_stack_size(<function>)
>
> that returns the maximum required stack size for <function>,
> multithreaded libraries could take advantage of it at run-time, in order
> to allocate only the amount of required memory.
Interesting idea :)
> This is of course not a complete proposal for something, just asking if
> something like that would be possible at all.
Well, it depends :)
Would __builtin_stack_size (F) retrieve information about F's stack frame
only, or would it also recursively account for every other function that
F may call ?
Implementing the former is probably possible, though I'm not sure
exactly how useful it would be.
The latter would no doubt be much^a_lot harder.