From d34cb6a14965380b1e0b8af0d5a8ff2f3c165055 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 14 Jan 2004 00:59:19 +0100 Subject: [PATCH] Partial fix PR c++/12850 Partial fix PR c++/12850 * cgraphunit.c (cgraph_finalize_function): Always ggc_collect when at zero nest level. * decl2.c (mark_used): Do not proactively instantiate templates when compiling in unit-at-a-time or not optimizing. * optimize.c (maybe_clone_body): Do not increase function depth. From-SVN: r75823 --- gcc/ChangeLog | 7 +++---- gcc/cgraphunit.c | 5 ++++- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl2.c | 9 ++++++++- gcc/cp/optimize.c | 7 ------- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2bcbf160355..5794b117deb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,9 +1,8 @@ 2004-01-14 Jan Hubicka - * c-common.c (c_estimate_num_insns_1): Fix bug in MODIFY_EXPR - cost estimation. - * expr.c (MOVE_RATIO, CLEAR_RATIO): Move to ... - * expr.h (MOVE_RATIO, CLEAR_RATIO): ... here. + Partial fix PR c++/12850 + * cgraphunit.c (cgraph_finalize_function): Always ggc_collect when + at zero nest level. 2004-01-13 Bernardo Innocenti diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index cf7069b1b08..e26a2c1730e 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -219,7 +219,10 @@ cgraph_finalize_function (tree decl, bool nested) /* If not unit at a time, go ahead and emit everything we've found to be reachable at this time. */ if (!nested) - cgraph_assemble_pending_functions (); + { + if (!cgraph_assemble_pending_functions ()) + ggc_collect (); + } /* If we've not yet emitted decl, tell the debug info about it. */ if (!TREE_ASM_WRITTEN (decl)) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 16e5f275e59..41a67d398bc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2004-01-14 Jan Hubicka + + Partial fix to PR c++/12850 + * decl2.c (mark_used): Do not proactively instantiate templates + when compiling in unit-at-a-time or not optimizing. + * optimize.c (maybe_clone_body): Do not increase function depth. + 2004-01-13 Giovanni Bajo PR c++/13474 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ef8ea6e310c..ec7b77dc659 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2580,6 +2580,7 @@ finish_file (void) /* If there are templates that we've put off instantiating, do them now. */ instantiate_pending_templates (); + ggc_collect (); /* Write out virtual tables as required. Note that writing out the virtual table for a template class may cause the @@ -3012,8 +3013,14 @@ mark_used (tree decl) However, if instantiating this function might help us mark the current function TREE_NOTHROW, we go ahead and - instantiate it now. */ + instantiate it now. + + This is not needed for unit-at-a-time since we reorder the functions + in topological order anyway. + */ defer = (!flag_exceptions + || flag_unit_at_a_time + || !optimize || TREE_CODE (decl) != FUNCTION_DECL /* If the called function can't throw, we don't need to generate its body to find that out. */ diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 7dc57ce31a3..1ddffc9c76c 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -129,11 +129,6 @@ maybe_clone_body (tree fn) /* Emit the DWARF1 abstract instance. */ (*debug_hooks->deferred_inline_function) (fn); - /* Our caller does not expect collection to happen, which it might if - we decide to compile the function to rtl now. Arrange for a new - gc context to be created if so. */ - function_depth++; - /* We know that any clones immediately follow FN in the TYPE_METHODS list. */ for (clone = TREE_CHAIN (fn); @@ -253,8 +248,6 @@ maybe_clone_body (tree fn) pop_from_top_level (); } - function_depth--; - /* We don't need to process the original function any further. */ return 1; }