From patchwork Tue May 17 08:27:51 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: 54084 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 7AE0F385735B for ; Tue, 17 May 2022 08:51:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AE0F385735B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652777498; bh=GGAw9UDgYsaasIky/+chl1VDJ2m+L5BsXi556pPuQtM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZWcwt1kWoIUaePAITgCVDzX6A1JBBV2sPYm09JCbx7gntHIxMOjETlCiHpvoTOe2r 2iY8zByXGPgX/8YYPJxa/3kYp5KohRyTpIMNB+5wyuPWZs3us9pTnPuL5oQuuBUTW4 /LiD/A+jgFiFC64jo02qAU+MSinGfMBWof99jo4M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 262FF3857822 for ; Tue, 17 May 2022 08:27:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 262FF3857822 Received: by mail-wr1-x42c.google.com with SMTP id r23so7637799wrr.2 for ; Tue, 17 May 2022 01:27:53 -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=GGAw9UDgYsaasIky/+chl1VDJ2m+L5BsXi556pPuQtM=; b=7/SgdIKN780AGuRoBAAv7p2b/PmYRYk7rksbVrcaqyl5/oZxMop9ZrCZrrXylVynJE 8xF3N/Y6BEdE3mlOcrxyZxzkkMTbsp8/HUZuATnfcDCnC7UQPCVelydMg+MkgcUcU6VB cK48te7UGK5jUF7lYLCUP6UebPH2XQ00pBkGxu3/yW3pbS9qkin6cSrnldL/YNDkd7Df miCe1I6LAZ25eghVSAJa8fS6bPc63zb00pRZiaHVirSklAuxI5AAXpV09dYixWdaIr8d k9P9nV7axTNsMktK10uGBmKAlBImKjI2iQ2+yD+yLbfwps8QN2zF0dB2ApMXhpklhLPP kUPg== X-Gm-Message-State: AOAM533PdaK+T4MsC+MN9tjWbFMc2xz9oUx5+AlZ9eJOc3YnjBD5huc+ vA8wvaZgVUUHmIC3SBYyzT7QW94f/d4ef0b3 X-Google-Smtp-Source: ABdhPJw5GbSQhvK66l/BrGiIUk2DRdwSG/ZTFeaH6UDQEIKf/fWIx0t+iJ0nwDF5oRehkHmKNJg3Mw== X-Received: by 2002:a5d:6b49:0:b0:20d:45a:98bd with SMTP id x9-20020a5d6b49000000b0020d045a98bdmr9560762wrw.446.1652776072739; Tue, 17 May 2022 01:27:52 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o28-20020adfa11c000000b0020d03c14b9csm6914205wro.1.2022.05.17.01.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 01:27:52 -0700 (PDT) Date: Tue, 17 May 2022 08:27:51 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Cleanups related to front-end SJLJ Message-ID: <20220517082751.GA1090664@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: Bob Duff Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch cleans up some code that is left over from the front-end SJLJ exception handling mechanism, which has been removed. This is in preparation for fixing a finalization-related bug. Most importantly: The documentation is changed: a Handled_Sequence_Of_Statements node CAN contain both Exception_Handlers and an At_End_Proc. The assertion contradicting that is removed from Expand_At_End_Handler. The From_At_End field is removed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sinfo.ads: Remove From_At_End. Update comments. * gen_il-fields.ads, gen_il-gen-gen_nodes.adb, sem_ch11.adb: Remove From_At_End. * exp_ch11.adb (Expand_At_End_Handler): Remove assertion. * fe.h (Exception_Mechanism, Exception_Mechanism_Type, Has_DIC, Has_Invariants, Is_List_Member, List_Containing): Remove declarations that are not used in gigi. * opt.ads (Exception_Mechanism): This is not used in gigi. * exp_util.ads: Minor comment fix. diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -85,8 +85,6 @@ package body Exp_Ch11 is pragma Unreferenced (Blk_Id); begin pragma Assert (Present (Entity (At_End_Proc (HSS)))); - pragma Assert (No (Exception_Handlers (HSS))); - return; end Expand_At_End_Handler; ------------------------------- diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -1105,8 +1105,8 @@ package Exp_Util is -- 1) controlled objects -- 2) library-level tagged types -- - -- These cases require special actions on scope exit. The flag Lib_Level - -- is set True if the construct is at library level, and False otherwise. + -- These cases require special actions on scope exit. Lib_Level is True if + -- the construct is at library level, and False otherwise. function Safe_Unchecked_Type_Conversion (Exp : Node_Id) return Boolean; -- Given the node for an N_Unchecked_Type_Conversion, return True if this diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h --- a/gcc/ada/fe.h +++ b/gcc/ada/fe.h @@ -207,7 +207,6 @@ extern Boolean In_Extended_Main_Code_Unit (Entity_Id); #define Enable_128bit_Types opt__enable_128bit_types #define Exception_Extra_Info opt__exception_extra_info #define Exception_Locations_Suppressed opt__exception_locations_suppressed -#define Exception_Mechanism opt__exception_mechanism #define Generate_SCO_Instance_Table opt__generate_sco_instance_table #define GNAT_Mode opt__gnat_mode #define List_Representation_Info opt__list_representation_info @@ -218,10 +217,6 @@ typedef enum { Ada_83, Ada_95, Ada_2005, Ada_2012, Ada_2022, Ada_With_Extensions } Ada_Version_Type; -typedef enum { - Back_End_ZCX, Back_End_SJLJ -} Exception_Mechanism_Type; - extern Ada_Version_Type Ada_Version; extern Boolean Assume_No_Invalid_Values; extern Boolean Back_End_Inlining; @@ -229,7 +224,6 @@ extern Boolean Debug_Generated_Code; extern Boolean Enable_128bit_Types; extern Boolean Exception_Extra_Info; extern Boolean Exception_Locations_Suppressed; -extern Exception_Mechanism_Type Exception_Mechanism; extern Boolean Generate_SCO_Instance_Table; extern Boolean GNAT_Mode; extern Int List_Representation_Info; @@ -645,12 +639,6 @@ B Is_Floating_Point_Type (E Id); #define Is_Record_Type einfo__utils__is_record_type B Is_Record_Type (E Id); -#define Has_DIC einfo__utils__has_dic -B Has_DIC (E Id); - -#define Has_Invariants einfo__utils__has_invariants -B Has_Invariants (E Id); - #define Is_Full_Access einfo__utils__is_full_access B Is_Full_Access (E Id); @@ -668,12 +656,6 @@ E Next_Stored_Discriminant (E Id); // fe.h is included before einfo.h. Entity_Kind Parameter_Mode (E Id); -#define Is_List_Member einfo__utils__is_list_member -B Is_List_Member (N Node); - -#define List_Containing einfo__utils__list_containing -S List_Containing (N Node); - // The following is needed because Convention in Sem_Util is a renaming // of Basic_Convention. diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads --- a/gcc/ada/gen_il-fields.ads +++ b/gcc/ada/gen_il-fields.ads @@ -191,7 +191,6 @@ package Gen_IL.Fields is Formal_Type_Definition, Forwards_OK, From_Aspect_Specification, - From_At_End, From_At_Mod, From_Conditional_Expression, From_Default, diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb --- a/gcc/ada/gen_il-gen-gen_nodes.adb +++ b/gcc/ada/gen_il-gen-gen_nodes.adb @@ -1043,8 +1043,7 @@ begin -- Gen_IL.Gen.Gen_Nodes Cc (N_Raise_Statement, N_Statement_Other_Than_Procedure_Call, (Sy (Name, Node_Id, Default_Empty), - Sy (Expression, Node_Id, Default_Empty), - Sm (From_At_End, Flag))); + Sy (Expression, Node_Id, Default_Empty))); Cc (N_Raise_When_Statement, N_Statement_Other_Than_Procedure_Call, (Sy (Name, Node_Id, Default_Empty), diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -585,16 +585,11 @@ package Opt is -- Similar to Back_End_ZCX with respect to the front-end processing -- of regular and AT-END handlers. A setjmp/longjmp scheme is used to -- propagate and setup handler contexts on regular execution paths. - pragma Convention (C, Exception_Mechanism_Type); - - -- WARNING: There is a matching C declaration of this type in fe.h Exception_Mechanism : Exception_Mechanism_Type := Back_End_SJLJ; -- GNAT -- Set to the appropriate value depending on the flags in system.ads - -- (ZCX_By_Default). The C convention is there to allow access by gigi. - - -- WARNING: There is a matching C declaration of this variable in fe.h + -- (ZCX_By_Default). function ZCX_Exceptions return Boolean; function SJLJ_Exceptions return Boolean; diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -611,15 +611,7 @@ package body Sem_Ch11 is else Set_Local_Raise_Not_OK (P); - - -- Do not check the restriction if the reraise statement is part - -- of the code generated for an AT-END handler. That's because - -- if the restriction is actually active, we never generate this - -- raise anyway, so the apparent violation is bogus. - - if not From_At_End (N) then - Check_Restriction (No_Exception_Propagation, N); - end if; + Check_Restriction (No_Exception_Propagation, N); end if; -- Normal case with exception id present diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1354,13 +1354,6 @@ package Sinfo is -- These generated nodes have the From_Aspect_Specification flag set to -- indicate that they came from aspect specifications originally. - -- From_At_End - -- This flag is set on an N_Raise_Statement node if it corresponds to - -- the reraise statement generated as the last statement of an AT END - -- handler when SJLJ exception handling is active. It is used to stop - -- a bogus violation of restriction (No_Exception_Propagation), bogus - -- because if the restriction is set, the reraise is not generated. - -- From_At_Mod -- This flag is set on the attribute definition clause node that is -- generated by a transformation of an at mod phrase in a record @@ -6811,38 +6804,24 @@ package Sinfo is -- The AT END phrase is a GNAT extension to provide for cleanups. It is -- used only internally currently, but is considered to be syntactic. - -- At the moment, the only cleanup action allowed is a single call to - -- a parameterless procedure, and the Identifier field of the node is - -- the procedure to be called. The cleanup action occurs whenever the - -- sequence of statements is left for any reason. The possible reasons - -- are: + -- At the moment, the only cleanup action allowed is a single call to a + -- parameterless procedure; this restriction could be lifted if we make + -- some changes in gigi. The At_End_Proc field is an N_Identifier node + -- that denotes the procedure to be called. The cleanup action occurs + -- whenever the sequence of statements is left for any reason. The + -- possible reasons are: + -- -- 1. reaching the end of the sequence -- 2. exit, return, or goto -- 3. exception or abort - -- For some back ends, such as gcc with ZCX, "at end" is implemented - -- entirely in the back end. In this case, a handled sequence of - -- statements with an "at end" cannot also have exception handlers. - -- For other back ends, such as gcc with front-end SJLJ, the - -- implementation is split between the front end and back end; the front - -- end implements 3, and the back end implements 1 and 2. In this case, - -- if there is an "at end", the front end inserts the appropriate - -- exception handler, and this handler takes precedence over "at end" - -- in case of exception. - - -- The inserted exception handler is of the form: - - -- when all others => - -- cleanup; - -- raise; - - -- where cleanup is the procedure to be called. The reason we do this is - -- so that the front end can handle the necessary entries in the - -- exception tables, and other exception handler actions required as - -- part of the normal handling for exception handlers. + -- + -- The cleanup action also occurs whenever the exception handlers are + -- left. -- The AT END cleanup handler protects only the sequence of statements - -- (not the associated declarations of the parent), just like exception - -- handlers. The big difference is that the cleanup procedure is called + -- and the exception handlers (not the associated declarations of + -- the parent), just like exception handlers do not protect the + -- declarations. The big difference is that the cleanup actions occur -- on either a normal or an abnormal exit from the statement sequence. -- Note: the list of Exception_Handlers can contain pragmas as well @@ -6873,6 +6852,9 @@ package Sinfo is -- At_End_Proc (set to Empty if no clean up procedure) -- First_Real_Statement + -- Note: A Handled_Sequence_Of_Statements can contain both + -- Exception_Handlers and an At_End_Proc. + -- Note: the parent always contains a Declarations field which contains -- declarations associated with the handled sequence of statements. This -- is true even in the case of an accept statement (see description of @@ -6936,7 +6918,6 @@ package Sinfo is -- Sloc points to RAISE -- Name (set to Empty if no exception name present) -- Expression (set to Empty if no expression present) - -- From_At_End ---------------------------- -- 11.3 Raise Expression --