From patchwork Thu May 19 14:15:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 54209 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3337383D804 for ; Thu, 19 May 2022 14:18:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3337383D804 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652969898; bh=ilNmvSUY/AASxEIVnJQ4Pv2wb3BxTWHpdnIMR8By4wg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CdRbJxdyawizR+0ezQ5kHttC8kq2LSI7g7b3iw/HBwLK/l/0RwyXifFBV5OazRqpP 8l0ajvnD731aDa4mDgPAsmMd1Jxw3Ld1BuUMTX411EVNcqUnKdph3acQ2+cfIcpdCI CJ4q42hxW50kMZ6iko5j8npLOFujzFZj7oj8UKcY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 72177385703E for ; Thu, 19 May 2022 14:15:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72177385703E Received: by mail-wm1-x332.google.com with SMTP id n6-20020a05600c3b8600b0039492b44ce7so2780367wms.5 for ; Thu, 19 May 2022 07:15:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=ilNmvSUY/AASxEIVnJQ4Pv2wb3BxTWHpdnIMR8By4wg=; b=Drw8dZq/v1IbOpjMXL5iZW87S+BoFigXzVgPdC2jfuHur0gmVdHnTW311mP8ZB8q9n GBzPILXgu9S+K7HtZx0SuGEFM08KPtXJWC9uxtt0lL/HR1vy4JNTEKGqGsch+stkPc2O tVDL2vEU0/upj6uP10eURue0zfOAtrrUV2sbPL88/5CMYKjxhS/AYIm3aqJ0BdT3CFiO 3nWHH+Wfq/ONoXSFF/K2V0bYqc2N4K93I9GEN2VqWMpc6zDBP0NNzFFYkY2cv7zYAwTC yTjO5rzeus8nCJOIzIWhi28On3t7oWLkIhm255GKizyR/SOUgB+fJAcb9771TdDlIfaW YHrg== X-Gm-Message-State: AOAM533yhjWGYwJA/zf0UOyR/WrEk9xjWlKBENAwWjDa1MeIYQrMcJEN xuv5SXfGXN6cgEyF78an/OBlN/7e1OjXlg== X-Google-Smtp-Source: ABdhPJwMaQD2SV3/XMPTw32JOwkAVGjfo0OYwJrWYZmr2VfvSSlpnmMSazd8uP8LqsAjmTftC7uDsA== X-Received: by 2002:a1c:4c06:0:b0:394:65c4:bd03 with SMTP id z6-20020a1c4c06000000b0039465c4bd03mr4123411wmf.8.1652969755169; Thu, 19 May 2022 07:15:55 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id x6-20020a05600c2d0600b00397342e3830sm780731wmf.0.2022.05.19.07.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 07:15:54 -0700 (PDT) Date: Thu, 19 May 2022 14:15:53 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Small housekeeping work continued Message-ID: <20220519141553.GA3723079@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/trans.cc: Fix formatting issues in comments. (Subprogram_Body_to_gnu): Tidy up. (Exception_Handler_to_gnu_gcc): Rename into... (Exception_Handler_to_gnu): ...this. (gnat_to_gnu) : Adjust to above renaming. diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -1149,9 +1149,9 @@ Gigi_Types_Compatible (Entity_Id type, Entity_Id def_type) return false; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an N_Identifier, - to a GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer - to where we should place the result type. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Identifier, to a GCC + tree, which is returned. GNU_RESULT_TYPE_P is a pointer to where we should + place the result type. */ static tree Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) @@ -1353,8 +1353,8 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) return gnu_result; } -/* Subroutine of gnat_to_gnu to process gnat_node, an N_Pragma. Return - any statements we generate. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Pragma, to a GCC + tree, which is returned. */ static tree Pragma_to_gnu (Node_Id gnat_node) @@ -1700,9 +1700,9 @@ get_type_length (tree type, tree result_type) return length; } -/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Attribute node, - to a GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer to - where we should place the result type. ATTRIBUTE is the attribute ID. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Attribute node, to a + GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer to where we + should place the result type. ATTRIBUTE is the attribute ID. */ static tree Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) @@ -2613,8 +2613,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) return gnu_result; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an N_Case_Statement, - to a GCC tree, which is returned. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Case_Statement, to a + GCC tree, which is returned. */ static tree Case_Statement_to_gnu (Node_Id gnat_node) @@ -2951,8 +2951,8 @@ independent_iterations_p (tree stmt_list) return true; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an N_Loop_Statement, - to a GCC tree, which is returned. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Loop_Statement, to a + GCC tree, which is returned. */ static tree Loop_Statement_to_gnu (Node_Id gnat_node) @@ -3836,22 +3836,19 @@ build_return_expr (tree ret_obj, tree ret_val) return build1 (RETURN_EXPR, void_type_node, result_expr); } -/* Subroutine of gnat_to_gnu to process gnat_node, an N_Subprogram_Body. We - don't return anything. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Subprogram_Body. */ static void Subprogram_Body_to_gnu (Node_Id gnat_node) { - /* Defining identifier of a parameter to the subprogram. */ - Entity_Id gnat_param; /* The defining identifier for the subprogram body. Note that if a specification has appeared before for this body, then the identifier - occurring in that specification will also be a defining identifier and all - the calls to this subprogram will point to that specification. */ + occurring in that specification will also be a defining identifier + and calls to this subprogram will point to that specification. */ Entity_Id gnat_subprog = (Present (Corresponding_Spec (gnat_node)) ? Corresponding_Spec (gnat_node) : Defining_Entity (gnat_node)); - /* The FUNCTION_DECL node corresponding to the subprogram spec. */ + /* The FUNCTION_DECL node corresponding to the defining identifier. */ tree gnu_subprog; /* Its RESULT_DECL node. */ tree gnu_result_decl; @@ -3860,11 +3857,9 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) /* The TYPE_CI_CO_LIST of its FUNCTION_TYPE node, if any. */ tree gnu_cico_list; /* The entry in the CI_CO_LIST that represents a function return, if any. */ - tree gnu_return_var_elmt = NULL_TREE; - tree gnu_result; + tree gnu_return_var_elmt; + /* Its source location. */ location_t locus; - struct language_function *gnu_subprog_language; - vec *cache; /* If this is a generic subprogram or it has been eliminated, ignore it. */ if (Is_Generic_Subprogram (gnat_subprog) || Is_Eliminated (gnat_subprog)) @@ -3886,9 +3881,11 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) gnu_cico_list = TYPE_CI_CO_LIST (gnu_subprog_type); if (gnu_cico_list && TREE_VALUE (gnu_cico_list) == void_type_node) gnu_return_var_elmt = gnu_cico_list; + else + gnu_return_var_elmt = NULL_TREE; /* If the function returns by invisible reference, make it explicit in the - function body. See gnat_to_gnu_entity, E_Subprogram_Type case. */ + function body. See gnat_to_gnu_subprog_type for more details. */ if (TREE_ADDRESSABLE (gnu_subprog_type)) { TREE_TYPE (gnu_result_decl) @@ -3910,8 +3907,8 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) /* Initialize the information structure for the function. */ allocate_struct_function (gnu_subprog, false); - gnu_subprog_language = ggc_cleared_alloc (); - DECL_STRUCT_FUNCTION (gnu_subprog)->language = gnu_subprog_language; + language_function *gnu_subprog_lang = ggc_cleared_alloc (); + DECL_STRUCT_FUNCTION (gnu_subprog)->language = gnu_subprog_lang; DECL_STRUCT_FUNCTION (gnu_subprog)->function_start_locus = locus; set_cfun (NULL); @@ -3923,7 +3920,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) block. */ if (gnu_cico_list) { - tree gnu_return_var = NULL_TREE; + tree gnu_return_var; vec_safe_push (gnu_return_label_stack, create_artificial_label (input_location)); @@ -3946,6 +3943,8 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) true, false, NULL, gnat_subprog); TREE_VALUE (gnu_return_var_elmt) = gnu_return_var; } + else + gnu_return_var = NULL_TREE; vec_safe_push (gnu_return_var_stack, gnu_return_var); @@ -3954,7 +3953,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) put it into TYPE_CI_CO_LIST, which must contain an empty entry too. We can match up the entries because TYPE_CI_CO_LIST is in the order of the parameters. */ - for (gnat_param = First_Formal_With_Extras (gnat_subprog); + for (Entity_Id gnat_param = First_Formal_With_Extras (gnat_subprog); Present (gnat_param); gnat_param = Next_Formal_With_Extras (gnat_param)) if (!present_gnu_tree (gnat_param)) @@ -3985,13 +3984,15 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) start_stmt_group (); gnat_pushlevel (); + /* First translate the declarations of the subprogram. */ process_decls (Declarations (gnat_node), Empty, Empty, true, true); - /* Generate the code of the subprogram itself. A return statement will be - present and any Out parameters will be handled there. */ + /* Then generate the code of the subprogram itself. A return statement will + be present and any Out parameters will be handled there. */ add_stmt (gnat_to_gnu (Handled_Statement_Sequence (gnat_node))); + gnat_poplevel (); - gnu_result = end_stmt_group (); + tree gnu_result = end_stmt_group (); /* Attempt setting the end_locus of our GCC body tree, typically a BIND_EXPR, then the end_locus of our GCC subprogram declaration tree. */ @@ -4001,7 +4002,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) /* If we populated the parameter attributes cache, we need to make sure that the cached expressions are evaluated on all the possible paths leading to their uses. So we force their evaluation on entry of the function. */ - cache = gnu_subprog_language->parm_attr_cache; + vec *cache = gnu_subprog_lang->parm_attr_cache; if (cache) { struct parm_attr_d *pa; @@ -4022,7 +4023,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) add_stmt (gnu_result); gnu_result = end_stmt_group (); - gnu_subprog_language->parm_attr_cache = NULL; + gnu_subprog_lang->parm_attr_cache = NULL; } /* If we are dealing with a return from an Ada procedure with parameters @@ -4116,7 +4117,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) /* Finally annotate the parameters and disconnect the trees for parameters that we have turned into variables since they are now unusable. */ - for (gnat_param = First_Formal_With_Extras (gnat_subprog); + for (Entity_Id gnat_param = First_Formal_With_Extras (gnat_subprog); Present (gnat_param); gnat_param = Next_Formal_With_Extras (gnat_param)) { @@ -4136,14 +4137,14 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) /* If the function returns an aggregate type and we have candidates for a Named Return Value, finalize the optimization. */ - if (optimize && !optimize_debug && gnu_subprog_language->named_ret_val) + if (optimize && !optimize_debug && gnu_subprog_lang->named_ret_val) { finalize_nrv (gnu_subprog, - gnu_subprog_language->named_ret_val, - gnu_subprog_language->other_ret_val, - gnu_subprog_language->gnat_ret); - gnu_subprog_language->named_ret_val = NULL; - gnu_subprog_language->other_ret_val = NULL; + gnu_subprog_lang->named_ret_val, + gnu_subprog_lang->other_ret_val, + gnu_subprog_lang->gnat_ret); + gnu_subprog_lang->named_ret_val = NULL; + gnu_subprog_lang->other_ret_val = NULL; } /* If this is an inlined external function that has been marked uninlinable, @@ -4463,7 +4464,7 @@ elaborate_profile (Entity_Id first_formal, Entity_Id result_type) (void) gnat_to_gnu_type (result_type); } -/* Subroutine of gnat_to_gnu to translate gnat_node, either an N_Function_Call +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Function_Call or an N_Procedure_Call_Statement, to a GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer to where we should place the result type. If GNU_TARGET is non-null, this must be a function call on the RHS of a @@ -5343,7 +5344,7 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, return gnu_result; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Handled_Sequence_Of_Statements, to a GCC tree, which is returned. */ static tree @@ -5487,12 +5488,11 @@ stmt_list_cannot_alter_control_flow_p (List_Id gnat_list) return true; } -/* Subroutine of gnat_to_gnu to translate gnat_node, an N_Exception_Handler, - to a GCC tree, which is returned. This is the variant for GCC exception - schemes. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Exception_Handler, + to a GCC tree, which is returned. */ static tree -Exception_Handler_to_gnu_gcc (Node_Id gnat_node) +Exception_Handler_to_gnu (Node_Id gnat_node) { tree gnu_etypes_list = NULL_TREE; @@ -5664,7 +5664,7 @@ Exception_Handler_to_gnu_gcc (Node_Id gnat_node) build2 (CATCH_EXPR, void_type_node, gnu_etypes_list, end_stmt_group ()); } -/* Subroutine of gnat_to_gnu to generate code for an N_Compilation unit. */ +/* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Compilation_Unit. */ static void Compilation_Unit_to_gnu (Node_Id gnat_node) @@ -5845,8 +5845,8 @@ Range_to_gnu (Node_Id gnat_range, tree *gnu_low, tree *gnu_high) } /* Subroutine of gnat_to_gnu to translate GNAT_NODE, an N_Raise_xxx_Error, - to a GCC tree and return it. GNU_RESULT_TYPE_P is a pointer to where - we should place the result type. */ + to a GCC tree, which is returned. GNU_RESULT_TYPE_P is a pointer to + where we should place the result type. */ static tree Raise_Error_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) @@ -7671,7 +7671,7 @@ gnat_to_gnu (Node_Id gnat_node) break; case N_Exception_Handler: - gnu_result = Exception_Handler_to_gnu_gcc (gnat_node); + gnu_result = Exception_Handler_to_gnu (gnat_node); break; case N_Raise_Statement: