diff options
author | froydnj <froydnj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-06 02:26:33 +0000 |
---|---|---|
committer | froydnj <froydnj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-06 02:26:33 +0000 |
commit | 2ab2ce89368289e93c9022aae8689f109c132f5c (patch) | |
tree | d191bb056818e7ad987268cffaf32a266a191f4c /gcc/tree-inline.c | |
parent | 01741c270449416238f8e70d812d0b71edcbd495 (diff) | |
download | gcc-2ab2ce89368289e93c9022aae8689f109c132f5c.tar.gz |
gcc/
* vec.h (FOR_EACH_VEC_ELT_REVERSE): New macro.
* function.h (struct_function): Change type of local_decls field
to a VEC.
(add_local_decl): New function.
(FOR_EACH_LOCAL_DECL): New macro.
* cfgexpand.c (init_vars_expansion): Adjust for new type of
cfun->local_decls.
(estimated_stack_frame_size): Likewise.
(expand_used_vars): Likewise.
* cgraphbuild.c (build_cgraph_edges): Likewise.
* function.c (instantiate_decls_1): Likewise.
* ipa-struct-reorg.c (build_data_structure): Likewise.
* ipa-type-escape.c (analyze_function): Likewise.
* lto-streamer-in.c (input_function): Likewise.
* lto-streamer-out.c (output_function): Likewise.
* tree-ssa-live.c (remove_unused_locals): Likewise.
* tree.c (free_lang_data_in_decl): Likewise.
(find_decls_types_in_node): Likewise.
* omp-low.c (remove_exit_barrier): Likewise.
(expand_omp_taskreg): Likewise.
(list2chain): Rename to...
(vec2chain): ...this. Adjust.
* cgraphunit.c (assemble_thunk): Call add_local_decl.
* tree-cfg.c (replace_by_duplicate_decl): Likewise.
* gimple-low.c (record_vars_into): Likewise.
* tree-inline.c (remap_decls): Likewise.
(declare_return_variable): Likewise.
(declare_inline_vars): Likewise.
(copy_forbidden): Adjust for new type of cfun->local_decls.
(add_local_variables): New function.
(expand_call_inline): Call it.
(tree_function_versioning): Likewise.
gcc/cp/
* decl.c (cp_finish_decl): Call add_local_decl.
* optimize.c (clone_body): Adjust for new type of cfun->local_decls.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161862 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 94 |
1 files changed, 41 insertions, 53 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 46c604f08fd..e295a6a5890 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -545,8 +545,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) if (TREE_CODE (old_var) == VAR_DECL && ! DECL_EXTERNAL (old_var) && (var_ann (old_var) || !gimple_in_ssa_p (cfun))) - cfun->local_decls = tree_cons (NULL_TREE, old_var, - cfun->local_decls); + add_local_decl (cfun, old_var); if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) && !DECL_IGNORED_P (old_var) && nonlocalized_list) @@ -2854,9 +2853,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest) } DECL_SEEN_IN_BIND_EXPR_P (var) = 1; - DECL_STRUCT_FUNCTION (caller)->local_decls - = tree_cons (NULL_TREE, var, - DECL_STRUCT_FUNCTION (caller)->local_decls); + add_local_decl (DECL_STRUCT_FUNCTION (caller), var); /* Do not have the rest of GCC warn about this variable as it should not be visible to the user. */ @@ -2915,7 +2912,8 @@ static const char * copy_forbidden (struct function *fun, tree fndecl) { const char *reason = fun->cannot_be_copied_reason; - tree step; + tree decl; + unsigned ix; /* Only examine the function once. */ if (fun->cannot_be_copied_set) @@ -2934,23 +2932,19 @@ copy_forbidden (struct function *fun, tree fndecl) goto fail; } - for (step = fun->local_decls; step; step = TREE_CHAIN (step)) - { - tree decl = TREE_VALUE (step); - - if (TREE_CODE (decl) == VAR_DECL - && TREE_STATIC (decl) - && !DECL_EXTERNAL (decl) - && DECL_INITIAL (decl) - && walk_tree_without_duplicates (&DECL_INITIAL (decl), - has_label_address_in_static_1, - fndecl)) - { - reason = G_("function %q+F can never be copied because it saves " - "address of local label in a static variable"); - goto fail; - } - } + FOR_EACH_LOCAL_DECL (fun, ix, decl) + if (TREE_CODE (decl) == VAR_DECL + && TREE_STATIC (decl) + && !DECL_EXTERNAL (decl) + && DECL_INITIAL (decl) + && walk_tree_without_duplicates (&DECL_INITIAL (decl), + has_label_address_in_static_1, + fndecl)) + { + reason = G_("function %q+F can never be copied because it saves " + "address of local label in a static variable"); + goto fail; + } fail: fun->cannot_be_copied_reason = reason; @@ -3737,6 +3731,26 @@ prepend_lexical_block (tree current_block, tree new_block) BLOCK_SUPERCONTEXT (new_block) = current_block; } +/* Add local variables from CALLEE to CALLER. */ + +static inline void +add_local_variables (struct function *callee, struct function *caller, + copy_body_data *id, bool check_var_ann) +{ + tree var; + unsigned ix; + + FOR_EACH_LOCAL_DECL (callee, ix, var) + if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) + { + if (!check_var_ann + || (var_ann (var) && add_referenced_var (var))) + add_local_decl (caller, var); + } + else if (!can_be_nonlocal (var, id)) + add_local_decl (caller, remap_decl (var, id)); +} + /* Fetch callee declaration from the call graph edge going from NODE and associated with STMR call statement. Return NULL_TREE if not found. */ static tree @@ -3769,8 +3783,6 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) gimple_stmt_iterator gsi, stmt_gsi; bool successfully_inlined = FALSE; bool purge_dead_abnormal_edges; - tree t_step; - tree var; /* Set input_location here so we get the right instantiation context if we call instantiate_decl from inlinable_function_p. */ @@ -3974,20 +3986,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) use_retvar = declare_return_variable (id, return_slot, modify_dest); /* Add local vars in this inlined callee to caller. */ - t_step = id->src_cfun->local_decls; - for (; t_step; t_step = TREE_CHAIN (t_step)) - { - var = TREE_VALUE (t_step); - if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) - { - if (var_ann (var) && add_referenced_var (var)) - cfun->local_decls = tree_cons (NULL_TREE, var, - cfun->local_decls); - } - else if (!can_be_nonlocal (var, id)) - cfun->local_decls = tree_cons (NULL_TREE, remap_decl (var, id), - cfun->local_decls); - } + add_local_variables (id->src_cfun, cfun, id, true); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -4729,7 +4728,7 @@ declare_inline_vars (tree block, tree vars) { DECL_SEEN_IN_BIND_EXPR_P (t) = 1; gcc_assert (!TREE_STATIC (t) && !TREE_ASM_WRITTEN (t)); - cfun->local_decls = tree_cons (NULL_TREE, t, cfun->local_decls); + add_local_decl (cfun, t); } if (block) @@ -5060,7 +5059,6 @@ tree_function_versioning (tree old_decl, tree new_decl, basic_block old_entry_block, bb; VEC (gimple, heap) *init_stmts = VEC_alloc (gimple, heap, 10); - tree t_step; tree old_current_function_decl = current_function_decl; tree vars = NULL_TREE; @@ -5185,19 +5183,9 @@ tree_function_versioning (tree old_decl, tree new_decl, declare_inline_vars (DECL_INITIAL (new_decl), vars); - if (DECL_STRUCT_FUNCTION (old_decl)->local_decls != NULL_TREE) + if (!VEC_empty (tree, DECL_STRUCT_FUNCTION (old_decl)->local_decls)) /* Add local vars. */ - for (t_step = DECL_STRUCT_FUNCTION (old_decl)->local_decls; - t_step; t_step = TREE_CHAIN (t_step)) - { - tree var = TREE_VALUE (t_step); - if (TREE_STATIC (var) && !TREE_ASM_WRITTEN (var)) - cfun->local_decls = tree_cons (NULL_TREE, var, cfun->local_decls); - else if (!can_be_nonlocal (var, &id)) - cfun->local_decls = - tree_cons (NULL_TREE, remap_decl (var, &id), - cfun->local_decls); - } + add_local_variables (DECL_STRUCT_FUNCTION (old_decl), cfun, &id, false); /* Copy the Function's body. */ copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE, |