This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to replace alloca with xmalloc
On Mon, Nov 01, 1999 at 07:01:14PM -0700, Jeffrey A Law wrote:
> In message <199911012250.PAA16709228@n02.acl.lanl.gov>you write:
> >
> > While looking at memory usage issues, I went barking up the wrong tree
> > for a while thinking that alloca was burning us. It turns out that we
> > don't usually alloca *that* much memory. On the other hand, we really
> > shouldn't be using alloca for lots of reasons:
> IMHO, allocas based on register #s, insn #s, bb#s or other values which can
> be potentially large need to be converted.
Yes, I agree the most critical things are the large allocas.
> I do not think we need to blindly convert every alloca. There are some cases
> where the semantics of alloca are perfect and we're allocating a small hunk
> of memory with a short lifetime.
>
> My point is not to convert everything blindly, but look critically at each one
> and ask "can this alloca call allocate large hunks of memory" (for some
> definition of large).
One advantage of converting alloca to xmalloc (not obstacks!) is that you can
link in checking versions of malloc to see whether you overrun the storage
space allocated.
--
Michael Meissner, Cygnus Solutions
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886
email: meissner@cygnus.com phone: 978-486-9304 fax: 978-692-4482