From patchwork Mon Dec 16 10:38:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1210244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516033-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="I4qP7Gju"; dkim-atps=neutral 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 47byWf0yRFz9sP6 for ; Mon, 16 Dec 2019 21:42:05 +1100 (AEDT) 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=lCYTa7ZOd6W60lxZq/TEKMocxAkCI/0lTyFC6cg3jxdRaRgHNM AUvTak5lCJ7JyTrHPe/oeDoZwbM/NJ4BauVJP5xbcTGOcBNHQ7XlyXaUOgMCZHdH qfAtCU0qwCuWScrEj8nbv9cMzcqZ7UW9kxtLoJHM/2vHmEeaABH60f76k= 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=W6w0zSJbulwF1P2okss/QbikQ3g=; b=I4qP7GjuDWTu9r+0sUiP 4EwxW+sQ5o73XzWQHaOrpSf5zSVE1Vmxbr7ZCZ+k7+Ra2rzSgMFs2gZi3uGh3eWv +I31M5zEp5oCe4hxz1ZFrtIS+hnoRD2cLdrooxpAtkUD//Q4HOa/1nOQ9r8Ro6pV /3xqIOKsz5NT3iNi2DgFqCI= Received: (qmail 76882 invoked by alias); 16 Dec 2019 10:38:42 -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 76411 invoked by uid 89); 16 Dec 2019 10:38:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=freezing, sk:Expand_, sk:expand_, UD:exp_ch8.adb X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Dec 2019 10:38:36 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ignlk-0006WI-9M for gcc-patches@gcc.gnu.org; Mon, 16 Dec 2019 05:38:30 -0500 Received: from rock.gnat.com ([205.232.38.15]:42059) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ignlk-0006TZ-2v for gcc-patches@gcc.gnu.org; Mon, 16 Dec 2019 05:38:28 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3402D56014; Mon, 16 Dec 2019 05:38:26 -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 lUDrLDlkdRhA; Mon, 16 Dec 2019 05:38:26 -0500 (EST) 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 1340E56010; Mon, 16 Dec 2019 05:38:26 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4862) id 124AB193; Mon, 16 Dec 2019 05:38:26 -0500 (EST) Date: Mon, 16 Dec 2019 05:38:26 -0500 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Expand renamings of subcomponents of an atomic or VFA object Message-ID: <20191216103826.GA39378@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 205.232.38.15 X-IsSubscribed: yes This change makes sure that the front-end expands the renamings of subcomponents of atomic or Volatile_Full_Access objects, i.e. the references in the renamed object are elaborated and the result is substituted for the renaming in the expanded code. This means that code generators implementing renaming by means of a pointer can keep doing it in the presence of atomic (in Ada 2020) or Volatile_Full_Access (in any version) objects in the source code. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-12-16 Eric Botcazou gcc/ada/ * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Document third special case of renamings requiring special handling. (Evaluation_Required): Return true for an atomic or VFA prefix. --- gcc/ada/exp_ch8.adb +++ gcc/ada/exp_ch8.adb @@ -72,7 +72,14 @@ package body Exp_Ch8 is -- clause applies (that can specify an arbitrary bit boundary), or where -- the enclosing record itself has a non-standard representation. - -- In these two cases, we pre-evaluate the renaming expression, by + -- In Ada 2020, a third case arises when the renamed object is a nonatomic + -- subcomponent of an atomic object, because reads of or writes to it must + -- access the enclosing atomic object. That's also the case for an object + -- subject to the Volatile_Full_Access GNAT aspect/pragma in any language + -- version. For the sake of simplicity, we treat any subcomponent of an + -- atomic or Volatile_Full_Access object in any language version this way. + + -- In these three cases, we pre-evaluate the renaming expression, by -- extracting and freezing the values of any subscripts, and then we -- set the flag Is_Renaming_Of_Object which means that any reference -- to the object will be handled by macro substitution in the front @@ -102,10 +109,10 @@ package body Exp_Ch8 is -- Determines whether it is necessary to do static name evaluation for -- renaming of Nam. It is considered necessary if evaluating the name -- involves indexing a packed array, or extracting a component of a - -- record to which a component clause applies. Note that we are only - -- interested in these operations if they occur as part of the name - -- itself, subscripts are just values that are computed as part of the - -- evaluation, so their form is unimportant. + -- record to which a component clause applies, or a subcomponent of an + -- atomic object. Note that we are only interested in these operations + -- if they occur as part of the name itself, subscripts are just values + -- that are computed as part of the evaluation, so they are unimportant. -- In addition, always return True for Modify_Tree_For_C since the -- code generator doesn't know how to handle renamings. @@ -121,6 +128,10 @@ package body Exp_Ch8 is elsif Nkind_In (Nam, N_Indexed_Component, N_Slice) then if Is_Packed (Etype (Prefix (Nam))) then return True; + + elsif Is_Atomic_Or_VFA_Object (Prefix (Nam)) then + return True; + else return Evaluation_Required (Prefix (Nam)); end if; @@ -141,6 +152,9 @@ package body Exp_Ch8 is then return True; + elsif Is_Atomic_Or_VFA_Object (Prefix (Nam)) then + return True; + else return Evaluation_Required (Prefix (Nam)); end if;