From patchwork Thu Jul 7 13:13:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 645887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rldNh2v19z9t22 for ; Thu, 7 Jul 2016 23:13:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fVmDMISj; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=gWsVltINbBvE5rWu96jZI140uw9ip+gArYAdReKd7CT+H3hwku Qm4BjQyUxIhw4yH7LNcCLJhVsLqb2WWZKptkNrj1KDHoQ65lNXtD30K6FtpkzTby xpdBrjCjLGU9Br6h9b+sGU0ESPKb9WsdM4eMjrpJhWt30PnMhXT2Z87aA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=cwR3qSyBDL4zlGT7VCR1iAHPpFc=; b=fVmDMISjtGma06rG/BAK PRAgXWq4Qq1iTkqbziWqoSGeD9Jf1XZfu869AorMBbcmv6zwK0TJvhUEOuqRErE5 YuLh6yT/lvMUVlYCCXHj3n/qQpFobP0hzEYyhBEAA7PzzfJ5icNyCyCxW1UdJ7ia Tt2726Wj1I1LR3aFR/AUxjg= Received: (qmail 48684 invoked by alias); 7 Jul 2016 13:13:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 48650 invoked by uid 89); 7 Jul 2016 13:13:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_40, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=H*Ad:U*ebotcazou, sk:Process, Decl, Analyzed X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 07 Jul 2016 13:13:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 20C49116D22; Thu, 7 Jul 2016 09:13:12 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25dHuQSyB8Af; Thu, 7 Jul 2016 09:13:12 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 0CFB1116740; Thu, 7 Jul 2016 09:13:12 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 093CD44D; Thu, 7 Jul 2016 09:13:12 -0400 (EDT) Date: Thu, 7 Jul 2016 09:13:12 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Clarify the semantics of -gnatn switch Message-ID: <20160707131312.GA42261@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This change is aimed at clarifying the semantics of the -gnatn switch, both in the code and in the documentation. In particular, it makes it explicit that -gnatn only pertains to inter-unit inlining (inlining across modules) and has no effect on intra-unit inlining (inlining within a given module). The patch also removes a couple of redundant/useless tests and disconnects an obsolete circuitry. No (visible) functional change. Tested on x86_64-pc-linux-gnu, committed on trunk 2016-07-07 Eric Botcazou * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Remove redundant test, adjust comments and formatting. * sem_prag.adb (Inlining_Not_Possible): Do not test Front_End_Inlining here but... (Make_Inline): ...here before calling Inlining_Not_Possible instead. (Set_Inline_Flags): Remove useless test. (Analyze_Pragma) : Add comment about -gnatn switch. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 238111) +++ sem_prag.adb (working copy) @@ -3932,7 +3932,7 @@ -- Enabled: inlining is requested/required for the subprogram procedure Process_Inline (Status : Inline_Status); - -- Common processing for Inline, Inline_Always and No_Inline. Parameter + -- Common processing for No_Inline, Inline and Inline_Always. Parameter -- indicates the inline status specified by the pragma. procedure Process_Interface_Name @@ -8791,21 +8791,20 @@ -- processing the arguments of the pragma. procedure Make_Inline (Subp : Entity_Id); - -- Subp is the defining unit name of the subprogram declaration. Set - -- the flag, as well as the flag in the corresponding body, if there - -- is one present. + -- Subp is the defining unit name of the subprogram declaration. If + -- the pragma is valid, call Set_Inline_Flags on Subp, as well as on + -- the corresponding body, if there is one present. procedure Set_Inline_Flags (Subp : Entity_Id); - -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also - -- Has_Pragma_Inline_Always for the Inline_Always case. + -- Set Has_Pragma_{No_Inline,Inline,Inline_Always} flag on Subp. + -- Also set or clear Is_Inlined flag on Subp depending on Status. function Inlining_Not_Possible (Subp : Entity_Id) return Boolean; -- Returns True if it can be determined at this stage that inlining -- is not possible, for example if the body is available and contains -- exception handlers, we prevent inlining, since otherwise we can -- get undefined symbols at link time. This function also emits a - -- warning if front-end inlining is enabled and the pragma appears - -- too late. + -- warning if the pragma appears too late. -- -- ??? is business with link symbols still valid, or does it relate -- to front end ZCX which is being phased out ??? @@ -8827,9 +8826,7 @@ elsif Nkind (Decl) = N_Subprogram_Declaration and then Present (Corresponding_Body (Decl)) then - if Front_End_Inlining - and then Analyzed (Corresponding_Body (Decl)) - then + if Analyzed (Corresponding_Body (Decl)) then Error_Msg_N ("pragma appears too late, ignored??", N); return True; @@ -8879,6 +8876,7 @@ -- If inlining is not possible, for now do not treat as an error elsif Status /= Suppressed + and then Front_End_Inlining and then Inlining_Not_Possible (Subp) then Applies := True; @@ -9048,9 +9046,7 @@ end if; end if; - if not Has_Pragma_Inline (Subp) then - Set_Has_Pragma_Inline (Subp); - end if; + Set_Has_Pragma_Inline (Subp); end if; -- Then adjust the Is_Inlined flag. It can never be set if the @@ -16398,8 +16394,24 @@ if not GNATprove_Mode then - -- Inline status is Enabled if inlining option is active + -- Inline status is Enabled if option -gnatn is specified. + -- However this status determines only the value of the + -- Is_Inlined flag on the subprogram and does not prevent + -- the pragma itself from being recorded for later use, + -- in particular for a later modification of Is_Inlined + -- independently of the -gnatn option. + -- In other words, if -gnatn is specified for a unit, then + -- all Inline pragmas processed for the compilation of this + -- unit, including those in the spec of other units, are + -- activated, so subprograms will be inlined across units. + + -- If -gnatn is not specified, no Inline pragma is activated + -- here, which means that subprograms will not be inlined + -- across units. The Is_Inlined flag will nevertheless be + -- set later when bodies are analyzed, so subprograms will + -- be inlined within the unit. + if Inline_Active then Process_Inline (Enabled); else Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 238106) +++ sem_ch6.adb (working copy) @@ -3731,7 +3731,7 @@ return; end if; - -- Handle front-end inlining + -- Handle inlining -- Note: Normally we don't do any inlining if expansion is off, since -- we won't generate code in any case. An exception arises in GNATprove @@ -3748,15 +3748,14 @@ if not Back_End_Inlining then if (Has_Pragma_Inline_Always (Spec_Id) - and then not Opt.Disable_FE_Inline_Always) - or else - (Has_Pragma_Inline (Spec_Id) and then Front_End_Inlining - and then not Opt.Disable_FE_Inline) + and then not Opt.Disable_FE_Inline_Always) + or else (Front_End_Inlining + and then not Opt.Disable_FE_Inline) then Build_Body_To_Inline (N, Spec_Id); end if; - -- New implementation (relying on backend inlining) + -- New implementation (relying on back-end inlining) else if Has_Pragma_Inline_Always (Spec_Id)