aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/optimize.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2000-07-27 21:10:29 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2000-07-27 21:10:29 +0000
commitb2244c65f518cfb4b6a5385ddfe45bc3ce2cf9c0 (patch)
treeba33209a933d13df9bd870697d71b7d7281a5b4e /gcc/cp/optimize.c
parent98be7846ad96810018215b97a636fa7777a8478f (diff)
downloadgcc-b2244c65f518cfb4b6a5385ddfe45bc3ce2cf9c0.zip
gcc-b2244c65f518cfb4b6a5385ddfe45bc3ce2cf9c0.tar.gz
gcc-b2244c65f518cfb4b6a5385ddfe45bc3ce2cf9c0.tar.bz2
cp-tree.h (function_depth): Declare.
* cp-tree.h (function_depth): Declare. (verify_stmt_tree): Likewise. (find_tree): Likewise. * decl.c (function_depth): Give it external linkage. * optimize.c (optimize_function): Increment and decrement it. * tree.c (verify_stmt_tree_r): New function. (verify_stmt_tree): Likewise. (find_tree_r): Likewise. (find_tree): Likewise. From-SVN: r35301
Diffstat (limited to 'gcc/cp/optimize.c')
-rw-r--r--gcc/cp/optimize.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 1f87c9c..c9898b8 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -801,6 +801,17 @@ void
optimize_function (fn)
tree fn;
{
+ /* While in this function, we may choose to go off and compile
+ another function. For example, we might instantiate a function
+ in the hopes of inlining it. Normally, that wouldn't trigger any
+ actual RTL code-generation -- but it will if the template is
+ actually needed. (For example, if it's address is taken, or if
+ some other function already refers to the template.) If
+ code-generation occurs, then garbage collection will occur, so we
+ must protect ourselves, just as we do while building up the body
+ of the function. */
+ ++function_depth;
+
/* Expand calls to inline functions. */
if (flag_inline_trees)
{
@@ -839,6 +850,9 @@ optimize_function (fn)
VARRAY_FREE (id.fns);
VARRAY_FREE (id.target_exprs);
}
+
+ /* Undo the call to ggc_push_context above. */
+ --function_depth;
}
/* Called from calls_setjmp_p via walk_tree. */