From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14212 invoked by alias); 13 Jul 2009 07:59:13 -0000 Received: (qmail 14187 invoked by uid 22791); 13 Jul 2009 07:59:11 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jul 2009 07:59:03 +0000 Received: from relay1.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 5B7EB5FC9F; Mon, 13 Jul 2009 09:59:00 +0200 (CEST) Date: Mon, 13 Jul 2009 07:59:00 -0000 From: Richard Guenther To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org, Diego Novillo , fortran@gcc.gnu.org, java@gcc.gnu.org Subject: Re: [PATCH] gimplify-unit-at-a-time (final) In-Reply-To: <200907101242.51197.ebotcazou@adacore.com> Message-ID: References: <200907101242.51197.ebotcazou@adacore.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00007.txt.bz2 On Fri, 10 Jul 2009, Eric Botcazou wrote: > > ada/ > > * utils.c (end_subprog_body): Revert to pre-tuples state. > > (gnat_gimplify_function): Do not gimplify here. > > (gnat_write_global_declarations): Also finalize the CU. > > * misc.c (gnat_parse_file): Do not finalize the CU here. > > * trans.c (gigi): Revert to pre-tuples state. > > The unused argument of end_subprog_body should be removed as well as > > ! /*cgraph_remove_node (cgraph_node (info->elab_proc));*/ > > and > > ! /* Process the function as others, but for indicating this is an > ! elab proc, to be discarded if empty, then propagate the status > ! up to the GNAT tree node. */ > > > It looks like gnat_gimplify_function is now useless; would it possible to get > rid of it and add > > dump_function (TDI_original, fndecl); > > to end_subprog_body right after the call to gnat_genericize? > > Otherwise looks OK. I'm testing the following (re-diffed ada/gcc-interface parts). /* We do different things for nested and non-nested functions. ??? This should be in cgraph. */ if (!DECL_CONTEXT (fndecl)) cgraph_finalize_function (fndecl, false); else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ (void) cgraph_node (fndecl); In theory this should be just cgraph_finalize_function (fndecl, DECL_CONTEXT (fndecl) != NULL_TREE); but I'll leave that to [m/n] of gigi housekeeping ;) Thanks, Richard. * utils.c (end_subprog_body): Revert to pre-tuples state. Remove unused parameter. (gnat_gimplify_function): Do not gimplify here. Fold into its only caller and remove. (gnat_builtin_function): Adjust for end_subprog_body signature change. (gnat_write_global_declarations): Also finalize the CU. * misc.c (gnat_parse_file): Do not finalize the CU here. * trans.c (gigi): Revert to pre-tuples state. (Subprogram_Body_to_gnu): Adjust for end_subprog_body signature change. * gigi.h (end_subprog_body): Remove unused parameter. Index: utils.c =================================================================== *** utils.c (revision 149545) --- utils.c (working copy) *************** static GTY((deletable)) tree free_block_ *** 203,209 **** static tree merge_sizes (tree, tree, tree, bool, bool); static tree compute_related_constant (tree, tree); static tree split_plus (tree, tree *); - static void gnat_gimplify_function (tree); static tree float_type_for_precision (int, enum machine_mode); static tree convert_to_fat_pointer (tree, tree); static tree convert_to_thin_pointer (tree, tree); --- 203,208 ---- *************** gnat_genericize (tree fndecl) *** 2070,2080 **** } /* Finish the definition of the current subprogram BODY and compile it all the ! way to assembler language output. ELAB_P tells if this is called for an ! elaboration routine, to be entirely discarded if empty. */ void ! end_subprog_body (tree body, bool elab_p) { tree fndecl = current_function_decl; --- 2069,2078 ---- } /* Finish the definition of the current subprogram BODY and compile it all the ! way to assembler language output. */ void ! end_subprog_body (tree body) { tree fndecl = current_function_decl; *************** end_subprog_body (tree body, bool elab_p *** 2107,2150 **** /* Perform the required pre-gimplification transformations on the tree. */ gnat_genericize (fndecl); /* We do different things for nested and non-nested functions. ??? This should be in cgraph. */ if (!DECL_CONTEXT (fndecl)) ! { ! gnat_gimplify_function (fndecl); ! ! /* If this is an empty elaboration proc, just discard the node. ! Otherwise, compile further. */ ! if (elab_p && empty_body_p (gimple_body (fndecl))) ! cgraph_remove_node (cgraph_node (fndecl)); ! else ! cgraph_finalize_function (fndecl, false); ! } else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ (void) cgraph_node (fndecl); } - /* Convert FNDECL's code to GIMPLE and handle any nested functions. */ - - static void - gnat_gimplify_function (tree fndecl) - { - struct cgraph_node *cgn; - - dump_function (TDI_original, fndecl); - gimplify_function_tree (fndecl); - dump_function (TDI_generic, fndecl); - - /* Convert all nested functions to GIMPLE now. We do things in this order - so that items like VLA sizes are expanded properly in the context of the - correct function. */ - cgn = cgraph_node (fndecl); - for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) - gnat_gimplify_function (cgn->decl); - } - tree gnat_builtin_function (tree decl) { --- 2105,2123 ---- /* Perform the required pre-gimplification transformations on the tree. */ gnat_genericize (fndecl); + /* Dump functions before gimplification. */ + dump_function (TDI_original, fndecl); + /* We do different things for nested and non-nested functions. ??? This should be in cgraph. */ if (!DECL_CONTEXT (fndecl)) ! cgraph_finalize_function (fndecl, false); else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ (void) cgraph_node (fndecl); } tree gnat_builtin_function (tree decl) { *************** build_function_stub (tree gnu_subprog, E *** 3520,3526 **** gnat_poplevel (); allocate_struct_function (gnu_stub_decl, false); ! end_subprog_body (gnu_body, false); } /* Build a type to be used to represent an aliased object whose nominal --- 3493,3499 ---- gnat_poplevel (); allocate_struct_function (gnu_stub_decl, false); ! end_subprog_body (gnu_body); } /* Build a type to be used to represent an aliased object whose nominal *************** gnat_write_global_declarations (void) *** 4693,4699 **** { /* Proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ ! cgraph_optimize (); /* Emit debug info for all global declarations. */ emit_debug_global_declarations (VEC_address (tree, global_decls), --- 4666,4672 ---- { /* Proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ ! cgraph_finalize_compilation_unit (); /* Emit debug info for all global declarations. */ emit_debug_global_declarations (VEC_address (tree, global_decls), Index: gigi.h =================================================================== *** gigi.h (revision 149545) --- gigi.h (working copy) *************** extern tree create_label_decl (tree labe *** 678,686 **** extern void begin_subprog_body (tree subprog_decl); /* Finish the definition of the current subprogram BODY and compile it all the ! way to assembler language output. ELAB_P tells if this is called for an ! elaboration routine, to be entirely discarded if empty. */ ! extern void end_subprog_body (tree body, bool elab_p); /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE. EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs. --- 678,685 ---- extern void begin_subprog_body (tree subprog_decl); /* Finish the definition of the current subprogram BODY and compile it all the ! way to assembler language output. */ ! extern void end_subprog_body (tree body); /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE. EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs. Index: trans.c =================================================================== *** trans.c (revision 149545) --- trans.c (working copy) *************** gigi (Node_Id gnat_root, int max_gnat_no *** 627,632 **** --- 627,633 ---- for (info = elab_info_list; info; info = info->next) { tree gnu_body = DECL_SAVED_TREE (info->elab_proc); + tree gnu_stmts; /* Unshare SAVE_EXPRs between subprograms. These are not unshared by the gimplifier for obvious reasons, but it turns out that we need to *************** gigi (Node_Id gnat_root, int max_gnat_no *** 638,651 **** an upstream bug for which we would not change the outcome. */ walk_tree_without_duplicates (&gnu_body, unshare_save_expr, NULL); - /* Process the function as others, but for indicating this is an - elab proc, to be discarded if empty, then propagate the status - up to the GNAT tree node. */ - begin_subprog_body (info->elab_proc); - end_subprog_body (gnu_body, true); ! if (empty_body_p (gimple_body (info->elab_proc))) ! Set_Has_No_Elaboration_Code (info->gnat_node, 1); } /* We cannot track the location of errors past this point. */ --- 639,662 ---- an upstream bug for which we would not change the outcome. */ walk_tree_without_duplicates (&gnu_body, unshare_save_expr, NULL); ! /* We should have a BIND_EXPR, but it may or may not have any statements ! in it. If it doesn't have any, we have nothing to do. */ ! gnu_stmts = gnu_body; ! if (TREE_CODE (gnu_stmts) == BIND_EXPR) ! gnu_stmts = BIND_EXPR_BODY (gnu_stmts); ! ! /* If there are no statements, there is no elaboration code. */ ! if (!gnu_stmts || !STATEMENT_LIST_HEAD (gnu_stmts)) ! { ! Set_Has_No_Elaboration_Code (info->gnat_node, 1); ! } ! else ! { ! /* Process the function as others. */ ! begin_subprog_body (info->elab_proc); ! end_subprog_body (gnu_body); ! } } /* We cannot track the location of errors past this point. */ *************** Subprogram_Body_to_gnu (Node_Id gnat_nod *** 2326,2332 **** : Sloc (gnat_node)), &DECL_STRUCT_FUNCTION (gnu_subprog_decl)->function_end_locus); ! end_subprog_body (gnu_result, false); /* Finally annotate the parameters and disconnect the trees for parameters that we have turned into variables since they are now unusable. */ --- 2337,2343 ---- : Sloc (gnat_node)), &DECL_STRUCT_FUNCTION (gnu_subprog_decl)->function_end_locus); ! end_subprog_body (gnu_result); /* Finally annotate the parameters and disconnect the trees for parameters that we have turned into variables since they are now unusable. */ Index: misc.c =================================================================== *** misc.c (revision 149545) --- misc.c (working copy) *************** gnat_parse_file (int set_yydebug ATTRIBU *** 176,184 **** /* Call the front end. */ _ada_gnat1drv (); - - /* We always have a single compilation unit in Ada. */ - cgraph_finalize_compilation_unit (); } /* Decode all the language specific options that cannot be decoded by GCC. --- 176,181 ----