aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1994-07-01 19:12:03 +0000
committerJason Merrill <merrill@gnu.org>1994-07-01 19:12:03 +0000
commit2b6c54d61d46d369cb0f889967ce7d17b9c5cca6 (patch)
tree9afce84c8326f9c4e02f87e28cbada31bddce6aa
parentfebd204ef6c2e8722ee1857560338609434e61ec (diff)
downloadgcc-2b6c54d61d46d369cb0f889967ce7d17b9c5cca6.zip
gcc-2b6c54d61d46d369cb0f889967ce7d17b9c5cca6.tar.gz
gcc-2b6c54d61d46d369cb0f889967ce7d17b9c5cca6.tar.bz2
(compile_file): Pass through static consts and inlines
multiple times in case they reference each other. From-SVN: r7633
-rw-r--r--gcc/toplev.c70
1 files changed, 46 insertions, 24 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index f648e6e..ad440ae 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2276,6 +2276,7 @@ compile_file (name)
tree *vec = (tree *) alloca (sizeof (tree) * len);
int i;
tree decl;
+ int reconsider = 1;
/* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */
@@ -2293,10 +2294,21 @@ compile_file (name)
if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
&& incomplete_decl_finalize_hook != 0)
(*incomplete_decl_finalize_hook) (decl);
+ }
- if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
- && ! TREE_ASM_WRITTEN (decl))
+ /* Now emit any global variables or functions that we have been putting
+ off. We need to loop in case one of the things emitted here
+ references another one which comes earlier in the list. */
+ while (reconsider)
+ {
+ reconsider = 0;
+ for (i = 0; i < len; i++)
{
+ decl = vec[i];
+
+ if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
+ continue;
+
/* Don't write out static consts, unless we still need them.
We also keep static consts if not optimizing (for debugging).
@@ -2321,30 +2333,40 @@ compile_file (name)
to force a constant to be written if and only if it is
defined in a main file, as opposed to an include file. */
- if (! TREE_READONLY (decl)
- || TREE_PUBLIC (decl)
- || !optimize
- || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
- rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
- else
- /* Cancel the RTL for this decl so that, if debugging info
- output for global variables is still to come,
- this one will be omitted. */
- DECL_RTL (decl) = NULL;
+ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
+ && (! TREE_READONLY (decl)
+ || TREE_PUBLIC (decl)
+ || !optimize
+ || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
+ {
+ reconsider = 1;
+ rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
+ }
+
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_INITIAL (decl) != 0
+ && DECL_SAVED_INSNS (decl) != 0
+ && (flag_keep_inline_functions
+ || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
+ {
+ reconsider = 1;
+ temporary_allocation ();
+ output_inline_function (decl);
+ permanent_allocation (1);
+ }
}
+ }
- if (TREE_CODE (decl) == FUNCTION_DECL
- && ! TREE_ASM_WRITTEN (decl)
- && DECL_INITIAL (decl) != 0
- && DECL_SAVED_INSNS (decl) != 0
- && (flag_keep_inline_functions
- || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
- && ! DECL_EXTERNAL (decl))
- {
- temporary_allocation ();
- output_inline_function (decl);
- permanent_allocation (1);
- }
+ for (i = 0; i < len; i++)
+ {
+ decl = vec[i];
+
+ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
+ && ! TREE_ASM_WRITTEN (decl))
+ /* Cancel the RTL for this decl so that, if debugging info
+ output for global variables is still to come,
+ this one will be omitted. */
+ DECL_RTL (decl) = NULL;
/* Warn about any function
declared static but not defined.