Commit 2b6c54d6 by Jason Merrill

(compile_file): Pass through static consts and inlines

        multiple times in case they reference each other.

From-SVN: r7633
parent febd204e
...@@ -2276,6 +2276,7 @@ compile_file (name) ...@@ -2276,6 +2276,7 @@ compile_file (name)
tree *vec = (tree *) alloca (sizeof (tree) * len); tree *vec = (tree *) alloca (sizeof (tree) * len);
int i; int i;
tree decl; tree decl;
int reconsider = 1;
/* Process the decls in reverse order--earliest first. /* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */ Put them into VEC from back to front, then take out from front. */
...@@ -2293,10 +2294,21 @@ compile_file (name) ...@@ -2293,10 +2294,21 @@ compile_file (name)
if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0
&& incomplete_decl_finalize_hook != 0) && incomplete_decl_finalize_hook != 0)
(*incomplete_decl_finalize_hook) (decl); (*incomplete_decl_finalize_hook) (decl);
}
if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) /* Now emit any global variables or functions that we have been putting
&& ! TREE_ASM_WRITTEN (decl)) 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. /* Don't write out static consts, unless we still need them.
We also keep static consts if not optimizing (for debugging). We also keep static consts if not optimizing (for debugging).
...@@ -2321,30 +2333,40 @@ compile_file (name) ...@@ -2321,30 +2333,40 @@ compile_file (name)
to force a constant to be written if and only if it is to force a constant to be written if and only if it is
defined in a main file, as opposed to an include file. */ defined in a main file, as opposed to an include file. */
if (! TREE_READONLY (decl) if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
|| TREE_PUBLIC (decl) && (! TREE_READONLY (decl)
|| !optimize || TREE_PUBLIC (decl)
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) || !optimize
rest_of_decl_compilation (decl, NULL_PTR, 1, 1); || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
else {
/* Cancel the RTL for this decl so that, if debugging info reconsider = 1;
output for global variables is still to come, rest_of_decl_compilation (decl, NULL_PTR, 1, 1);
this one will be omitted. */ }
DECL_RTL (decl) = NULL;
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 for (i = 0; i < len; i++)
&& ! TREE_ASM_WRITTEN (decl) {
&& DECL_INITIAL (decl) != 0 decl = vec[i];
&& DECL_SAVED_INSNS (decl) != 0
&& (flag_keep_inline_functions if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) && ! TREE_ASM_WRITTEN (decl))
&& ! DECL_EXTERNAL (decl)) /* Cancel the RTL for this decl so that, if debugging info
{ output for global variables is still to come,
temporary_allocation (); this one will be omitted. */
output_inline_function (decl); DECL_RTL (decl) = NULL;
permanent_allocation (1);
}
/* Warn about any function /* Warn about any function
declared static but not defined. declared static but not defined.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment