This is the mail archive of the
mailing list for the GCC project.
Re: Copying collection and our ggc_collect practices
On Wed, 17 Sep 2003, Zack Weinberg wrote:
> Daniel Berlin <email@example.com> writes:
> > On Wed, 17 Sep 2003, Zack Weinberg wrote:
> >> Daniel Berlin <firstname.lastname@example.org> writes:
> >> > Currently, gcc has a bad habit of keeping ggc_alloc'd pointers in unmarked
> >> > local variables, and expecting the addresses not to change over a
> >> > ggc_collect.
> >> Could you give examples?
> > Sure, here's one.
> > In cgraphunit.c, cgraph_expand_functions stores cgraph_node * (which are
> > ggc_alloc'd) in the order array, which is xcalloc'd and unmarked. It calls
> > cgraph_expand_function which calls the expand_function hook which calls
> > ggc_collect.
> Ok, so that's pretty easy to turn into a file-scope static as ggc
> needs. I seriously suggest you do a sweep, find all of these, and fix
But it's actually a bit worse than that.
The node argument to cgraph_expand_function can itself change address
before and after the call to the expand_function hook (that calls ggc_collect).
Thus, you have to make cgraph_expand_function's argument marked as well,
which means removing and making it static, and setting it before calling
the function rather than passing an argue.
I don't think there are that many places where we do this type of thing
(call ggc_collect in the middle of a function and expect our local
pointers to still be valid), but they aren't easy to track down. :P