From patchwork Tue Jul 17 10:15:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 171387 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 A31E62C0127 for ; Tue, 17 Jul 2012 20:15:30 +1000 (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=1343124930; 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=z+qj18v6Qr5TO67gvx7a f3JozNQ=; b=kk/HD9IKzcrKalClmEY3OrYnlKMi5MUAPsNpeWajHu+DfE01pV/I F2OsBwYep29fyEefmX0fA9SCMBPxg4O0khdqjPwrWK/q2+p8Pj34BpAkL6SayW3h ycKykQx4CNEfZ818H03jm9/AWxfB5BEETdAMzjv5hX4Gli89g1vucUU= 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=KaN2Y0xwHueRqVyOIU56BGyV5LQEVv93REvaut4v/eA608Otw7SNJp0ptrHIMt kZuWTvOIFK4T1q8sPARSPO69RcNjpMagI70jjN5nru4kqKZ/HBgzkXV5sDRqbSYd KgmMz7iRohxrKvnbmBqqYmbQqzVy1ml4h1xJCXgLSjHrw=; Received: (qmail 30979 invoked by alias); 17 Jul 2012 10:15:20 -0000 Received: (qmail 30869 invoked by uid 22791); 17 Jul 2012 10:15:18 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO, TW_TM 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; Tue, 17 Jul 2012 10:15:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D7F091C6EEC; Tue, 17 Jul 2012 06:15:00 -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 02LA1pYQsYmv; Tue, 17 Jul 2012 06:15:00 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id AFEC11C6280; Tue, 17 Jul 2012 06:15:00 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id ACA8E3FF09; Tue, 17 Jul 2012 06:15:00 -0400 (EDT) Date: Tue, 17 Jul 2012 06:15:00 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Minor tweak to expanded code for transient objects Message-ID: <20120717101500.GA25937@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 change makes it so that the finalization blocks generated for controlled transient objects, as well the final raise statement, are all wrapped into a block, so as to make it easier for the back-end to understand the construct. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-17 Eric Botcazou * exp_ch7.adb (Process_Transient_Objects): Put all the finalization blocks and the final raise statement into a wrapper block. Index: exp_ch7.adb =================================================================== --- exp_ch7.adb (revision 189565) +++ exp_ch7.adb (working copy) @@ -4390,6 +4390,7 @@ Obj_Id : Entity_Id; Obj_Ref : Node_Id; Obj_Typ : Entity_Id; + Prev_Fin : Node_Id := Empty; Stmt : Node_Id; Stmts : List_Id; Temp_Id : Entity_Id; @@ -4428,7 +4429,6 @@ Fin_Decls := New_List; Build_Object_Declarations (Fin_Data, Fin_Decls, Loc); - Insert_List_Before_And_Analyze (First_Object, Fin_Decls); Built := True; end if; @@ -4560,15 +4560,25 @@ Exception_Handlers => New_List ( Build_Exception_Handler (Fin_Data)))); - Insert_After_And_Analyze (Last_Object, Fin_Block); + -- The single raise statement must be inserted after all the + -- finalization blocks. And we put everything into a wrapper + -- block to clearly expose the construct to the back-end. - -- The raise statement must be inserted after all the - -- finalization blocks. + if Present (Prev_Fin) then + Insert_Before_And_Analyze (Prev_Fin, Fin_Block); + else + Insert_After_And_Analyze (Last_Object, + Make_Block_Statement (Loc, + Declarations => Fin_Decls, + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List (Fin_Block)))); - if No (Last_Fin) then Last_Fin := Fin_Block; end if; + Prev_Fin := Fin_Block; + -- When the associated node is an array object, the expander may -- sometimes generate a loop and create transient objects inside -- the loop.