This is the mail archive of the 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]

[tree-ssa] lower nested functions

The following implements a scheme I posted some months ago:

Tested on i686, alphaev67 and x86-64-linux.  More interesting would
have been ia64, but none of our ia64 machines seem to be able to make
it through a bootstrap (before or after) without panicing.  Oh well.

There is one expected C regression, compile/20010605-1.c.  This is
a nasty gimplification problem.  While looking at this, I came up
with a number of related test cases that ICE on *any* version of gcc.
I'll have to think about that I want to do here.

Unfortunately, this also exposes some bugs in the Fortran front end.
The end result isn't as bad as I feared earlier this weekend -- we
get about 20 new failures on i686.  The problems stem from having to
convert the front end to use the cgraph interfaces, but the front end
itself violates the one decl per object rule, which results in much
confusion.  I talked with pbrook and stevenb about the problem on irc
yesterday; they were aware of the pre-existing condition, just hadn't
gotten around to fixing it yet.  I promised to get "close", and then
Steven would pick up what's left.


	* tree-nested.c: New file.
	* (OBJS-common, GTFILES, tree-nested.o): Add it.
	* builtin-types.def (BT_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR_PTR): New.
	* builtins.c (expand_builtin_nonlocal_goto): New.
	(expand_builtin_apply): Fix prepare_call_address args.
	(round_trampoline_addr): Move from function.c.
	(expand_builtin_init_trampoline): New.
	(expand_builtin_adjust_trampoline): New.
	(expand_builtin): Invoke them.
	(build_function_call_expr): Add CALL_EXPR chain operand.
	* builtins.def (BUILT_IN_INIT_TRAMPOLINE,
	* c-decl.c (finish_function): Call lower_nested_functions.
	(c_expand_decl): Don't declare_nonlocal_label.
	* calls.c (prepare_call_address): Replace fndecl arg with a
	precomputed static chain value.  
	(expand_call): Precompute the static chain value.  Use
	* cgraph.c (cgraph_mark_reachable_node): Don't force nested
	functions to be reachable.
	(cgraph_clone_node): Don't abort cloning functions containing
	nested functions.
	* cgraphunit.c (cgraph_assemble_pending_functions): Don't do
	anything special for nested functions.
	(cgraph_mark_functions_to_output): Likewise.
	(cgraph_estimate_growth, cgraph_clone_inlined_nodes): Likewise.
	(cgraph_optimize): Likewise.
	(cgraph_finalize_function): Don't zap DECL_SAVED_INSNS.
	(cgraph_expand_function): Allow functions to not be emitted.
	* defaults.h (TRAMPOLINE_ALIGNMENT): Move from function.c.
	* dwarf2out.c (gen_subprogram_die): Generate DW_AT_static_link.
	* emit-rtl.c (maybe_set_first_label_num): New.
	* explow.c (update_nonlocal_goto_save_area): New.
	(allocate_dynamic_stack_space): Use it.
	* expr.c (expand_expr_real_1) <LABEL_DECL>: Don't force_label_rtx.
	<COND_EXPR>: Ignore the possibility of non-local labels.
	<ADDR_EXPR>: Don't do trampoline_address.
	* expr.h (lookup_static_chain): Remove.
	(prepare_call_address): Update 2nd arg.
	(update_nonlocal_goto_save_area): Declare.
	* final.c (profile_function): Update static chain test.
	* function.c (TRAMPOLINE_ALIGNMENT): Move to defaults.h.
	(trampolines_created): Move to varasm.c.
	(free_after_compilation): Update for removed fields.
	(allocate_struct_function): Likewise.
	(delete_handlers, lookup_static_chain): Remove.
	(fix_lexical_addr): Don't consider non-local variable refs.
	(trampoline_address): Remove.
	(round_trampoline_addr): Move to builtins.c.
	(adjust_trampoline_addr): Remove.
	(expand_function_start): Update for changes to static chain
	and nonlocal goto handling.
	(initial_trampoline): Move to varasm.c.
	(expand_function_end): Don't build trampolines or kill
	unreferenced nonlocal goto labels.
	* function.h (struct function): Remove x_nonlocal_labels,
	x_nonlocal_goto_handler_slots, x_nonlocal_goto_stack_level,
	x_context_display, x_trampoline_list, needs_context.
	Add static_chain_decl, nonlocal_goto_save_area.
	* gimple-low.c (record_vars): Don't record functions.
	* gimplify.c (declare_tmp_vars): Export.
	(create_artificial_label): Set type.
	(gimplify_expr): Don't consider nonlocal gotos.
	* integrate.c (expand_inline_function): Kill lookup_static_chain ref.
	* jump.c (any_uncondjump_p): Reject nonlocal goto.
	* rtl.h (maybe_set_first_label_num): Declare.
	* stmt.c (label_rtx): Set LABEL_PRESERVE_P appropriately.
	(expand_label): Handle DECL_NONLOCAL and FORCED_LABEL.
	(declare_nonlocal_label): Remove.
	(expand_goto): Don't handle nonlocal gotos.
	(expand_nl_handler_label): Remove.
	(expand_nl_goto_receivers): Remove.
	(expand_end_bindings): Don't expand_nl_goto_receivers.  Use
	* tree-cfg.c (make_edges): Handle abnormal edges out of block
	falling through to EXIT.
	(make_ctrl_stmt_edges): Don't check GOTO_EXPR for nonlocal goto.
	Handle computed goto with no destinations.
	(tree_can_merge_blocks_p): Don't merge blocks with nonlocal labels.
	(remove_useless_stmts_label, stmt_starts_bb_p): Likewise.
	(tree_forwarder_block_p): Likewise.
	(nonlocal_goto_p): Remove.
	(tree_verify_flow_info): Update to match.
	* tree-dump.c (dump_files): Add tree-nested.
	* tree-flow.h (nonlocal_goto_p): Remove.
	* tree-inline.c (setup_one_parameter): Split out from ...
	(initialize_inlined_parameters): ... here.  Handle static chain.
	(inline_forbidden_p_1): Update nonlocal goto check.
	(expand_call_inline): Disable mysterious cgraph abort.
	* tree-optimize.c (tree_rest_of_compilation): Save DECL_SAVED_INSNS.
	* tree-pretty-print.c (dump_generic_node): Print static chain
	and nonlocal label.
	* tree-simple.h (declare_tmp_vars): Declare.
	(lower_nested_functions): Declare.
	* tree-ssa-dom.c (propagate_value): Avoid sharing problems.
	* tree-ssa-operands.c (get_expr_operands): Walk static chain
	field of call_expr.
	* tree.def (CALL_EXPR): Add static chain operand.
	* tree.h (NONLOCAL_LABEL): Remove.
	(TDI_nested): New.
	* varasm.c (TRAMPOLINE_ALIGNMENT): Remove.
	(initial_trampoline): Move from function.c.
	(assemble_trampoline_template): Set and return it.
	(trampolines_created): Move from function.c.
        * utils.c (max_size): Add static chain op for call_expr.
        * call.c (build_call, build_over_call, build_new_method_call): Add
        static chain operand to call_expr.
        * decl.c (build_offset_ref_call_from_tree): Likewise.
        * parser.c (cp_parser_postfix_expression): Likewise.
        * semantics.c (finish_call_expr): Likewise.
        * cp-lang.c (cp_expand_decl): Don't declare_nonlocal_label.
        * (f95-lang.o, trans-decl.o): Depend on cgraph.h.
        * f95-lang.c (LANG_HOOKS_EXPAND_DECL): Remove.
        (gfc_expand_function): Rename from expand_function_body, make static,
        don't do anything except invoke tree_rest_of_compilation.
        (gfc_be_parse_file): Invoke cgraph.
        (gfc_expand_decl): Remove.
        (gfc_init_builtin_functions): Add __builtin_init_trampoline and
        * trans-decl.c (gfc_get_extern_function_decl): Don't set DECL_CONTEXT.
        (gfc_finalize): New.
        (gfc_generate_function_code): Use it.  Lower nested functions.
        * trans-expr.c (gfc_conv_function_call): Add static chain operand
        to call_expr.
        * trans.c (gfc_build_function_call): Likewise.
        * trans.h (expand_function_body): Remove.
        * builtins.c (java_build_function_call_expr): Add static chain
        operand to call_expr.

Attachment: d-nest-6.gz
Description: GNU Zip compressed data

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