aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lang.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-12 00:02:36 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-12 00:02:36 +0000
commitbf1846b66aa8330947d0b73164c483e9709e8652 (patch)
tree98496e95cb60a38b607a253c73d876f87f5d80fd /gcc/c-lang.c
parente51fa9235f6c37bf6d7e094c1347d5b62488262d (diff)
* Makefile.in (c-lang.o): Depend on $(VARRAY_H).
* c-decl.c (c_expand_body): Take argument can_defer_p. Use it to decide whether to defer a function. (finish_function): Adjust. (c_expand_deferred_function): New function. * c-lang.c (deferred_fns): New variable. (c_init): Initialize it, and mark it as a root. (defer_fn): New function. (finish_file): Expand all deferred functions. * c-tree.h (defer_fn): Declare. (c_expand_deferred_function): Likewise. * objc/Make-lang.in (objc-act.o): Depend on $(VARRAY_H). * objc-act.c (deferred_fns): New variable. (objc_init): Initialize it, and mark it as a root. (defer_fn): New function. (finish_file): Expand all deferred functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46933 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lang.c')
-rw-r--r--gcc/c-lang.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index 67c860b7900..d6644582fba 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "cpplib.h"
#include "insn-config.h"
#include "integrate.h"
+#include "varray.h"
#include "langhooks.h"
#include "langhooks-def.h"
@@ -79,6 +80,8 @@ static int c_cannot_inline_tree_fn PARAMS ((tree *));
/* Each front end provides its own. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+static varray_type deferred_fns;
+
/* Post-switch processing. */
static void
c_post_options ()
@@ -136,6 +139,9 @@ c_init ()
lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
c_parse_init ();
+
+ VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
+ ggc_add_tree_varray_root (&deferred_fns, 1);
}
/* Used by c-lex.c, but only for objc. */
@@ -242,11 +248,33 @@ finish_cdtor (body)
}
#endif
+/* Register a function tree, so that its optimization and conversion
+ to RTL is only done at the end of the compilation. */
+
+int
+defer_fn (fn)
+ tree fn;
+{
+ VARRAY_PUSH_TREE (deferred_fns, fn);
+
+ return 1;
+}
+
/* Called at end of parsing, but before end-of-file processing. */
void
finish_file ()
{
+ int i;
+
+ for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_fns); i++)
+ /* Don't output the same function twice. We may run into such
+ situations when an extern inline function is later given a
+ non-extern-inline definition. */
+ if (! TREE_ASM_WRITTEN (VARRAY_TREE (deferred_fns, i)))
+ c_expand_deferred_function (VARRAY_TREE (deferred_fns, i));
+ VARRAY_FREE (deferred_fns);
+
#ifndef ASM_OUTPUT_CONSTRUCTOR
if (static_ctors)
{