From patchwork Mon Jul 16 13:04:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 171185 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 836452C0093 for ; Mon, 16 Jul 2012 23:04:45 +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=1343048685; 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=XqmcTyAh0KbCriCnhznz pzxAnhw=; b=S4+nalE+eU3FUPUiPkVUDSVv5rUGRXGJH9oAdAaLxICLRLlBeGyg DS2IEoZ8rDK92/hwrpqtVKNTi3m9YW7Ad4GD89NJtrMNiPN4WoLEIXHHh6ELnx9U 1WOPrz1aifPMCnSzREilWMuaDoqsISokKUc8hb00gdC8PuqzN+gzQpo= 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=xwX29Y8nd9bi9HI5V8jNw4zdZ8Y0ptCMGpYA9KVbzoMvRbxglOJEtZO7xkU2R0 iz0p1yFp+s97+rTpTGXf1WvmSxOo+SMx+YcRQOY+xbw/lIe586AmWg9qcn9kMbHm KCWcDTasAl7NeDh2iSuC5FmOi8+fhXO/jIFwxTq7r4k30=; Received: (qmail 7164 invoked by alias); 16 Jul 2012 13:04:37 -0000 Received: (qmail 7150 invoked by uid 22791); 16 Jul 2012 13:04:36 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_50, RCVD_IN_HOSTKARMA_NO 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; Mon, 16 Jul 2012 13:04:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0490E1C6495; Mon, 16 Jul 2012 09:04:22 -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 FmNJ7GH6TSH8; Mon, 16 Jul 2012 09:04:21 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id C047F1C6450; Mon, 16 Jul 2012 09:04:21 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id BC92F3FF09; Mon, 16 Jul 2012 09:04:21 -0400 (EDT) Date: Mon, 16 Jul 2012 09:04:21 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Thomas Quinot Subject: [Ada] Coverage analysis of select statements Message-ID: <20120716130421.GA32181@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 introduces generation of a null statement in alternatives appearing in various forms of select statement, when they do not have trailing statements. The purpose of the additional null statement is to allow a nop to be generated with an appropriate source location indication in debug information, for coverage analysis purposes. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-16 Thomas Quinot * exp_ch9.adb (Ensure_Statement_Present): New subprogram. (Expand_N_Asynchronous_Select, Expand_N_Selective_Accept.Process_Accept_Alternative, Expand_N_Selective_Accept.Process_Delay_Alternative, Expand_N_Timed_Entry_Call): For an alternative with no trailing statements, introduce a null statement to carry the sloc of the initial special statement (accept, delay, or entry call) in the alternative, for coverage analysis purposes. Index: exp_ch9.adb =================================================================== --- exp_ch9.adb (revision 189534) +++ exp_ch9.adb (revision 189535) @@ -339,6 +339,17 @@ -- step of the expansion must to be done after private data has been moved -- to its final resting scope to ensure proper visibility of debug objects. + procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id); + -- If control flow optimizations are suppressed, and Alt is an accept, + -- delay, or entry call alternative with no trailing statements, insert a + -- null trailing statement with the given Loc (which is the sloc of the + -- accept, delay, or entry call statement). There might not be any + -- generated code for the accept, delay, or entry call itself (the + -- effect of these statements is part of the general processsing done + -- for the enclosing selective accept, timed entry call, or asynchronous + -- select), and the null statement is there to carry the sloc of that + -- statement to the back-end for trace-based coverage analysis purposes. + procedure Extract_Dispatching_Call (N : Node_Id; Call_Ent : out Entity_Id; @@ -5468,6 +5479,19 @@ end loop; end Debug_Private_Data_Declarations; + ------------------------------ + -- Ensure_Statement_Present -- + ------------------------------ + + procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id) is + begin + if Opt.Suppress_Control_Flow_Optimizations + and then Is_Empty_List (Statements (Alt)) + then + Set_Statements (Alt, New_List (Make_Null_Statement (Loc))); + end if; + end Ensure_Statement_Present; + ---------------------------- -- Entry_Index_Expression -- ---------------------------- @@ -6587,7 +6611,7 @@ Abortable_Block : Node_Id; Actuals : List_Id; Astats : List_Id; - Blk_Ent : Entity_Id; + Blk_Ent : constant Entity_Id := Make_Temporary (Loc, 'A'); Blk_Typ : Entity_Id; Call : Node_Id; Call_Ent : Entity_Id; @@ -6632,15 +6656,16 @@ Process_Statements_For_Controlled_Objects (Trig); Process_Statements_For_Controlled_Objects (Abrt); + Ecall := Triggering_Statement (Trig); + + Ensure_Statement_Present (Sloc (Ecall), Trig); + -- Retrieve Astats and Tstats now because the finalization machinery may -- wrap them in blocks. Astats := Statements (Abrt); Tstats := Statements (Trig); - Blk_Ent := Make_Temporary (Loc, 'A'); - Ecall := Triggering_Statement (Trig); - -- The arguments in the call may require dynamic allocation, and the -- call statement may have been transformed into a block. The block -- may contain additional declarations for internal entities, and the @@ -10301,6 +10326,8 @@ Alt_Stats := New_List; end if; + Ensure_Statement_Present (Sloc (Astmt), Alt); + -- After the call, if any, branch to trailing statements, if any. -- We create a label for each, as well as the corresponding label -- declaration. @@ -10330,6 +10357,7 @@ ------------------------------- procedure Process_Delay_Alternative (Alt : Node_Id; Index : Int) is + Dloc : constant Source_Ptr := Sloc (Delay_Statement (Alt)); Choices : List_Id; Cond : Node_Id; Delay_Alt : List_Id; @@ -10433,6 +10461,8 @@ Append_List (Delay_Alt, Delay_List); + Ensure_Statement_Present (Dloc, Alt); + -- If the delay alternative has a statement part, add choice to the -- case statements for delays. @@ -11884,6 +11914,8 @@ Process_Statements_For_Controlled_Objects (E_Alt); Process_Statements_For_Controlled_Objects (D_Alt); + Ensure_Statement_Present (Sloc (D_Stat), D_Alt); + -- Retrieve E_Stats and D_Stats now because the finalization machinery -- may wrap them in blocks.