From patchwork Fri Mar 9 14:48:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 145724 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]) by ozlabs.org (Postfix) with SMTP id AC503B6FA3 for ; Sat, 10 Mar 2012 01:49:42 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331909382; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=4tZ2YbBSsHMW2ep/acdi 1TlBJUY=; b=aQXcJdCj2MgkRb+qxKZxSyUMwrvfkXdbHmGsIyFdDbloXCKcAoBi HDcgvgzwsyKmEPijb0X48aiM0JeUwLlwE0WNhXaIUGolACxi4c91LKIpnj4hJ+D/ AgtbND743E8Kf5rtbHNtCmR0JiwSTBCilVodf+hRoaJdxgeD5NuQbN0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=EsXNLzLwLmeoNZvh0J5fxBpRR8a9MNHtd6TpI5Rf6XDMp7GPxu8fVToFpMs2B3 n52c1hnpo+EkI18j9yPsF7vZWwQbAtf1qjsA7h07vFaPR4sq60lvW6O/vYkFpwC7 3NtLVdVIJfoD8jRt+7SiezYMLLaNDrLnZB0gTKQmleDAs=; Received: (qmail 6144 invoked by alias); 9 Mar 2012 14:49:20 -0000 Received: (qmail 6109 invoked by uid 22791); 9 Mar 2012 14:49:11 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Mar 2012 14:48:45 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7E0C91C6BAA; Fri, 9 Mar 2012 09:48:40 -0500 (EST) 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 tWe8R8JEsvWm; Fri, 9 Mar 2012 09:48:40 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 513B51C6BA8; Fri, 9 Mar 2012 09:48:40 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id 40A393FEE8; Fri, 9 Mar 2012 09:48:40 -0500 (EST) Date: Fri, 9 Mar 2012 09:48:40 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Adding new frontend support for inlining Message-ID: <20120309144840.GA2308@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This patch adjusts the behavior of the wavefront to incorporate frontend inlining support when compiling on AMMP or VM targets. This new support is temporarily available using -gnatd.k These are the rules: * At -O0, or compiling on AAMP or VM targets, use fe inlining when inline_always is specified except if the function returns a controlled type. The deprecated switch -gnatN can be used at this level. * At other optimization levels use the fe inlining for both inline and inline_always in the following cases: - function returning a known at compile time constant - function returning a call to an intrinsic function - function returning an unconstrained type through an Ada 2005 extended return statement - function returning a call to a frontend-inlined function Use the back-end mechanism otherwise Tested on x86_64-pc-linux-gnu, committed on trunk 2012-03-09 Javier Miranda * sem_ch6.adb (Check_Body_To_Inline): In AAMP and VM targets use frontend inlining at all optimization levels. * sem_util.adb (Must_Inline): In AAMP and VM targets, given that there is no inlining support in the backend, use also frontend inlining when compiling with optimizations enabled. * exp_ch6.adb (Expand_Call): Minor code reorganization. Index: sem_util.adb =================================================================== --- sem_util.adb (revision 185136) +++ sem_util.adb (working copy) @@ -9422,7 +9422,13 @@ function Must_Inline (Subp : Entity_Id) return Boolean is begin - return Optimization_Level = 0 + -- AAMP and VM targets have no support for inlining in the backend. + -- Hence we do as much inlining as possible in the front end. + + return + (Optimization_Level = 0 + or else AAMP_On_Target + or else VM_Target /= No_VM) and then Has_Pragma_Inline (Subp) and then (Has_Pragma_Inline_Always (Subp) or else Front_End_Inlining); end Must_Inline; Index: exp_ch6.adb =================================================================== --- exp_ch6.adb (revision 185136) +++ exp_ch6.adb (working copy) @@ -3790,10 +3790,7 @@ Spec : constant Node_Id := Unit_Declaration_Node (Subp); begin - if Optimization_Level > 0 then - Do_Inline (Subp, Orig_Subp); - - elsif Must_Inline (Subp) then + if Must_Inline (Subp) then if In_Extended_Main_Code_Unit (Call_Node) and then In_Same_Extended_Unit (Sloc (Spec), Loc) and then not Has_Completion (Subp) @@ -3805,6 +3802,9 @@ else Do_Inline_Always (Subp, Orig_Subp); end if; + + elsif Optimization_Level > 0 then + Do_Inline (Subp, Orig_Subp); end if; -- The call may have been inlined or may have been passed to Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 185136) +++ sem_ch6.adb (working copy) @@ -4888,9 +4888,13 @@ Remove (Body_To_Analyze); -- Keep separate checks needed when compiling without optimizations + -- AAMP and VM targets have no support for inlining in the backend + -- and hence we use frontend inlining at all optimization levels. - if Optimization_Level = 0 then - + if Optimization_Level = 0 + or else AAMP_On_Target + or else VM_Target /= No_VM + then -- Cannot inline functions whose body has a call that returns an -- unconstrained type since the secondary stack is involved, and -- it is not worth inlining.