This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Extend thunk support and use it in Ada


On 9/25/18 4:21 AM, Eric Botcazou wrote:
> Hi,
> 
> this extends the support for thunks present in the middle-end to accomodate 
> the Ada language, which can generate more diverse thunks than C++.  The main 
> couple of enhancements are:
>  1. Indirect offsets used to implement thunks for self-referential types,
>  2. Local thunks used to implement thunks for types defined locally.
> 
> It's done entirely in the middle-end, i.e. the interface with the back-end is 
> not changed, the rationale being that the vast majority of thunks generated in 
> Ada are the same as those generated in C++.
> 
> This should be transparent for C++, except for the calls.c change which causes 
> thunks not generated by the back-end to use a tailcall even at -O0 when that's 
> possible, since that's what most of the back-ends do too.
> 
> Tested x86-64/Linux, OK for the mainline?
> 
> 
> 2018-09-25  Eric Botcazou  <ebotcazou@adacore.com>
>             Pierre-Marie de Rodat  <derodat@adacore.com>
>             Javier Miranda  <miranda@adacore.com>
> 
> 	* 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.
> 	* 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.
> 	* lto-cgraph.c (lto_output_node): Write indirect_offset field.
> 	(input_node): Write 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/
> 	* exp_disp.adb (Expand_Interface_Conversion): Use Present test.
> 	(Expand_Interface_Thunk): Propagate debug info setting from target.
> 	* exp_util.ads (Find_Interface_Tag): Adjust comment.
> 	* exp_util.adb (Find_Interface_Tag): Remove assertions of success.
> 	* sem_res.adb (Resolve_Actuals): If the formal is a class-wide type
>  	conversion then do not skip resolving and expanding the conversion.
> 	* sem_util.adb (Is_Variable_Size_Record): Only look at components
> 	and robustify the implementation.
> 	* fe.h (Find_Interface_Tag): Declare.
> 	(Is_Variable_Size_Record): Likewise.
> 	* 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.
The non-Ada parts look good to me.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]