gc problem with nested functions
Jim Wilson
wilson@cygnus.com
Fri Sep 10 15:35:00 GMT 1999
Your Sept 3 change broke nested functions.
Fri Sep 3 18:16:01 1999 Bernd Schmidt <bernds@cygnus.co.uk>
Change obstack memory management and varasm constant pool handling so
that nested functions are treated like any other functions.
...
(immed_double_const): Don't walk const_double_chain outside a
function, but don't treat nested functions specially anymore.
The particular problem I saw is segmentation faults from the ia64 port
while compiling execute/920612-2.c with optimization. It died in
immed_double_const while searching const_double_chain, because there was
invalid RTL on that list.
The invalid RTL occurs because nested functions have current_obstack pointing
to the permanent_obstack. Combine allocates undobuf on the current obstack,
and then frees it if a combination fails. Since this is the permanent_obstack,
this also causes us to free the RTL that is allocated in immed_double_constant.
Nested functions have current_obstack pointing at permanent_obstack so that
we can easily save all RTL generated for the function until the end of the
module. Normally, this would be the temporary_obstack, and it would be
freed when we are done with the function.
When the gc stuff is done, this shouldn't be a problem, but meanwhile I think
we still need special treatment for nested functions here.
Alternatively, for nested functions, we might try to switch current_obstack
from the permanent_obstack to the temporary_obstack after RTL generation ends
but before RTL optimization starts. However, I suspect that it will be
tricky to get this right, and I didn't want to try it.
I haven't checked this in yet, in case you wanted to make a comment or
suggestion. I expect to check this in Monday unless someone comes up with
a better solution.
Fri Sep 10 14:57:48 1999 Jim Wilson <wilson@cygnus.com>
* varasm.c (immed_double_const): Treat nested functions specially
again.
Index: varasm.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/varasm.c,v
retrieving revision 1.240
diff -p -r1.240 varasm.c
*** varasm.c 1999/09/07 04:13:47 1.240
--- varasm.c 1999/09/10 21:57:11
*************** immed_double_const (i0, i1, mode)
*** 2087,2093 ****
pop_obstacks ();
/* Don't touch const_double_chain if not inside any function. */
! if (current_function_decl != 0)
{
CONST_DOUBLE_CHAIN (r) = const_double_chain;
const_double_chain = r;
--- 2087,2100 ----
pop_obstacks ();
/* Don't touch const_double_chain if not inside any function. */
! /* ??? Also don't touch const_double_chain if we are inside a nested
! function. This is because nested functions have current_obstack pointing
! to permanent_obstack instead of the normal temporary_obstack, thus the
! above switch to the permanent obstack does not make the RTL safe. This
! is particularly a problem if called from combine. Combine does an obfree
! if a combination fails, thus freeing the RTL we just allocated above.
! There may be other places that cause similar problems. */
! if (outer_function_chain == 0 && current_function_decl != 0)
{
CONST_DOUBLE_CHAIN (r) = const_double_chain;
const_double_chain = r;
More information about the Gcc-patches
mailing list