From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id E5EB1395563E for ; Thu, 2 Jun 2022 09:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5EB1395563E Received: by mail-ej1-x630.google.com with SMTP id rq11so8727386ejc.4 for ; Thu, 02 Jun 2022 02:09:04 -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=wGN35nYDLrt3mIfGNbecwWaM7K0v7ARUKxp67TgRGSI=; b=S5UVT1pBqqYVISyJmCz7W6EGbRl/1QFzXFm0W4jSowQlDv4sRvpVdV/ALsMtExD54g YYWc0+r56k46ttYnPnPxBx7uSDbbaeCI1OwRqLypIhp4Wgt9Rw52GNB9LH4nPtFh5qBW MW8fjQjqNOreuXy5fzGihjh6/Unoskegb1bVFTN9XfcGScWx7wAxZT9jxNKXRvbll+GR fFaPqToOy98VhuR89TpfHbbkYDi0G8CkyDrSgfl6kL6G+5DgK1JIIb1SzPZhPtXXXqOq sRQK9xA6muBp1XXvC9hF36niU7eD0eYTpM4afgJzT/JfdGzctx1c12v8lrRGMUUVhAMW uESQ== X-Gm-Message-State: AOAM530yTl8B16ypi1xnyKfFZeyAEzLgeqsIQSZlW0jMA3TO1jEh3Dhm erYLApxUYUIol21YT7lFXwMS3EWetyXC6g== X-Google-Smtp-Source: ABdhPJx7/Zl8mPvxdTiRujIY9LeMMKPpIPSOKQ/R02CqmW8+S6kEpbvcJqtuBoXVSitAVZo6HEqADQ== X-Received: by 2002:a17:906:f51:b0:6fe:cf1c:cdbf with SMTP id h17-20020a1709060f5100b006fecf1ccdbfmr3192428ejj.695.1654160943655; Thu, 02 Jun 2022 02:09:03 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id f27-20020a17090624db00b006f3ef214dcdsm1560584ejb.51.2022.06.02.02.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 02:09:03 -0700 (PDT) Date: Thu, 2 Jun 2022 09:09:02 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Refine previous changes on making symbols public/private Message-ID: <20220602090902.GA1010792@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" 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-List-Received-Date: Thu, 02 Jun 2022 09:09:06 -0000 --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Inline_Always procedures should be kept public for proper inter unit inlining. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch7.adb (Set_Referencer_Of_Non_Subprograms): New local procedure, used for code refactoring. Also take into account Inline_Always pragma when deciding to make a symbol public for C generation. --5vNYLRcllDrimb99 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -304,6 +304,46 @@ package body Sem_Ch7 is Decl_Id : Entity_Id; In_Instance : Boolean; Spec : Node_Id; + Ignore : Boolean; + + function Set_Referencer_Of_Non_Subprograms return Boolean; + -- Set Has_Referencer_Of_Non_Subprograms and call + -- Scan_Subprogram_Refs if relevant. + -- Return whether Scan_Subprogram_Refs was called. + + --------------------------------------- + -- Set_Referencer_Of_Non_Subprograms -- + --------------------------------------- + + function Set_Referencer_Of_Non_Subprograms return Boolean is + begin + -- An inlined subprogram body acts as a referencer + -- unless we generate C code since inlining is then + -- handled by the C compiler. + + -- Note that we test Has_Pragma_Inline here in addition + -- to Is_Inlined. We are doing this for a client, since + -- we are computing which entities should be public, and + -- it is the client who will decide if actual inlining + -- should occur, so we need to catch all cases where the + -- subprogram may be inlined by the client. + + if (not CCG_Mode or else Has_Pragma_Inline_Always (Decl_Id)) + and then (Is_Inlined (Decl_Id) + or else Has_Pragma_Inline (Decl_Id)) + then + Has_Referencer_Of_Non_Subprograms := True; + + -- Inspect the statements of the subprogram body + -- to determine whether the body references other + -- subprograms. + + Scan_Subprogram_Refs (Decl); + return True; + else + return False; + end if; + end Set_Referencer_Of_Non_Subprograms; begin if No (Decls) then @@ -398,54 +438,17 @@ package body Sem_Ch7 is return True; end if; - -- An inlined subprogram body acts as a referencer - -- unless we generate C code since inlining is then - -- handled by the C compiler. - - -- Note that we test Has_Pragma_Inline here in addition - -- to Is_Inlined. We are doing this for a client, since - -- we are computing which entities should be public, and - -- it is the client who will decide if actual inlining - -- should occur, so we need to catch all cases where the - -- subprogram may be inlined by the client. - - if not CCG_Mode - and then (Is_Inlined (Decl_Id) - or else Has_Pragma_Inline (Decl_Id)) - then - Has_Referencer_Of_Non_Subprograms := True; - - -- Inspect the statements of the subprogram body - -- to determine whether the body references other - -- subprograms. - - Scan_Subprogram_Refs (Decl); - end if; + Ignore := Set_Referencer_Of_Non_Subprograms; -- Otherwise this is a stand alone subprogram body else Decl_Id := Defining_Entity (Decl); - -- An inlined subprogram body acts as a referencer - -- unless we generate C code since inlining is then - -- handled by the C compiler. - - if not CCG_Mode - and then (Is_Inlined (Decl_Id) - or else Has_Pragma_Inline (Decl_Id)) + if not Set_Referencer_Of_Non_Subprograms + and then not Subprogram_Table.Get (Decl_Id) then - Has_Referencer_Of_Non_Subprograms := True; - - -- Inspect the statements of the subprogram body - -- to determine whether the body references other - -- subprograms. - - Scan_Subprogram_Refs (Decl); - - -- Otherwise we can reset Is_Public right away - - elsif not Subprogram_Table.Get (Decl_Id) then + -- We can reset Is_Public right away Set_Is_Public (Decl_Id, False); end if; end if; --5vNYLRcllDrimb99--