diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2018-09-28 21:20:53 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2018-09-28 21:20:53 +0000 |
commit | 44662f681e8be6b3b7eafcec4afa0ecb8cc587cd (patch) | |
tree | 1c0470d4d2c3d3ea333d09879f17a86087934d93 /gcc/tree-nested.c | |
parent | 5c441345a343d0ef90e5ac9ef95039030ecef1ee (diff) | |
download | gcc-44662f681e8be6b3b7eafcec4afa0ecb8cc587cd.zip gcc-44662f681e8be6b3b7eafcec4afa0ecb8cc587cd.tar.gz gcc-44662f681e8be6b3b7eafcec4afa0ecb8cc587cd.tar.bz2 |
calls.c (expand_call): Try to do a tail call for thunks at -O0 too.
* calls.c (expand_call): Try to do a tail call for thunks at -O0 too.
* cgraph.h (struct cgraph_thunk_info): Add indirect_offset.
(cgraph_node::create_thunk): Add indirect_offset parameter.
(thunk_adjust): Likewise.
* cgraph.c (cgraph_node::create_thunk): Add indirect_offset parameter
and initialize the corresponding field with it.
(cgraph_node::dump): Dump indirect_offset field.
* cgraphclones.c (duplicate_thunk_for_node): Deal with indirect_offset.
* cgraphunit.c (cgraph_node::analyze): Be prepared for external thunks.
(thunk_adjust): Add indirect_offset parameter and deal with it.
(cgraph_node::expand_thunk): Deal with the indirect_offset field and
pass it to thunk_adjust. Do not call the target hook if it's non-zero
or if the thunk is external or local. Fix formatting. Do not chain
the RESULT_DECL to BLOCK_VARS. Pass the static chain to the target,
if any, in the GIMPLE representation.
* ipa-icf.c (sem_function::equals_wpa): Deal with indirect_offset.
* lto-cgraph.c (lto_output_node): Write indirect_offset field.
(input_node): Read indirect_offset field.
* tree-inline.c (expand_call_inline): Pass indirect_offset field in the
call to thunk_adjust.
* tree-nested.c (struct nesting_info): Add thunk_p field.
(create_nesting_tree): Set it.
(convert_all_function_calls): Copy static chain from targets to thunks.
(finalize_nesting_tree_1): Return early for thunks.
(unnest_nesting_tree_1): Do not finalize thunks.
(gimplify_all_functions): Do not gimplify thunks.
cp/
* method.c (use_thunk): Adjust call to cgraph_node::create_thunk.
ada/
* gcc-interface/decl.c (is_cplusplus_method): Do not require C++
convention on Interfaces.
* gcc-interface/trans.c (Subprogram_Body_to_gnu): Try to create a
bona-fide thunk and hand it over to the middle-end.
(get_controlling_type): New function.
(use_alias_for_thunk_p): Likewise.
(thunk_labelno): New static variable.
(make_covariant_thunk): New function.
(maybe_make_gnu_thunk): Likewise.
* gcc-interface/utils.c (finish_subprog_decl): Set DECL_CONTEXT of the
result DECL here instead of...
(end_subprog_body): ...here.
Co-Authored-By: Pierre-Marie de Rodat <derodat@adacore.com>
From-SVN: r264701
Diffstat (limited to 'gcc/tree-nested.c')
-rw-r--r-- | gcc/tree-nested.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 4c8eda9..4579b4c 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -104,6 +104,7 @@ struct nesting_info tree chain_decl; tree nl_goto_field; + bool thunk_p; bool any_parm_remapped; bool any_tramp_created; bool any_descr_created; @@ -834,6 +835,7 @@ create_nesting_tree (struct cgraph_node *cgn) info->mem_refs = new hash_set<tree *>; info->suppress_expansion = BITMAP_ALLOC (&nesting_info_bitmap_obstack); info->context = cgn->decl; + info->thunk_p = cgn->thunk.thunk_p; for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) { @@ -2786,6 +2788,8 @@ convert_all_function_calls (struct nesting_info *root) within the debugger. */ FOR_EACH_NEST_INFO (n, root) { + if (n->thunk_p) + continue; tree decl = n->context; if (!optimize) { @@ -2806,6 +2810,14 @@ convert_all_function_calls (struct nesting_info *root) chain_count += DECL_STATIC_CHAIN (decl); } + FOR_EACH_NEST_INFO (n, root) + if (n->thunk_p) + { + tree decl = n->context; + tree alias = cgraph_node::get (decl)->thunk.alias; + DECL_STATIC_CHAIN (decl) = DECL_STATIC_CHAIN (alias); + } + /* Walk the functions and perform transformations. Note that these transformations can induce new uses of the static chain, which in turn require re-examining all users of the decl. */ @@ -2825,12 +2837,22 @@ convert_all_function_calls (struct nesting_info *root) FOR_EACH_NEST_INFO (n, root) { + if (n->thunk_p) + continue; tree decl = n->context; walk_function (convert_tramp_reference_stmt, convert_tramp_reference_op, n); walk_function (convert_gimple_call, NULL, n); chain_count += DECL_STATIC_CHAIN (decl); } + + FOR_EACH_NEST_INFO (n, root) + if (n->thunk_p) + { + tree decl = n->context; + tree alias = cgraph_node::get (decl)->thunk.alias; + DECL_STATIC_CHAIN (decl) = DECL_STATIC_CHAIN (alias); + } } while (chain_count != old_chain_count); @@ -3055,12 +3077,13 @@ build_init_call_stmt (struct nesting_info *info, tree decl, tree field, static void finalize_nesting_tree_1 (struct nesting_info *root) { - gimple_seq stmt_list; + gimple_seq stmt_list = NULL; gimple *stmt; tree context = root->context; struct function *sf; - stmt_list = NULL; + if (root->thunk_p) + return; /* If we created a non-local frame type or decl, we need to lay them out at this time. */ @@ -3340,7 +3363,8 @@ unnest_nesting_tree_1 (struct nesting_info *root) if (node->origin) { node->unnest (); - cgraph_node::finalize_function (root->context, true); + if (!root->thunk_p) + cgraph_node::finalize_function (root->context, true); } } @@ -3380,7 +3404,8 @@ gimplify_all_functions (struct cgraph_node *root) if (!gimple_body (root->decl)) gimplify_function_tree (root->decl); for (iter = root->nested; iter; iter = iter->next_nested) - gimplify_all_functions (iter); + if (!iter->thunk.thunk_p) + gimplify_all_functions (iter); } /* Main entry point for this pass. Process FNDECL and all of its nested |