From patchwork Mon Jan 16 14:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 44185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1230739wrn; Mon, 16 Jan 2023 06:50:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGztFE6d8eFSuzTON/lwHSPhmyFx5rfJaJYKG6w+Q5NjZ5c2PDWZo8tkLSDse9ivvm7BOZ X-Received: by 2002:a17:907:100c:b0:86c:a3ed:1442 with SMTP id ox12-20020a170907100c00b0086ca3ed1442mr9078457ejb.4.1673880613597; Mon, 16 Jan 2023 06:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673880613; cv=none; d=google.com; s=arc-20160816; b=LUg5zdu51XTQD/Q8F5gMqbqGO89FJSz6JzMujzPvjHO0/HaeIzhaWFH4p9F6OIGxUX wF3BkNhpZYQ4ks14o5kt9R2jlOH7mNykmAHyyhV03+tqiV/5L1vaLOi2yWO34cHUx5FW Jh1C0wZYaGje/tRdqB0rhqwaYuqCTgSm8bwhkrdcZJMxoSevGDxROq0LUVJBa9VcBkkW zq2oUuUYoBnB8cZ2o/VZYaXI7yZJeP16SaO6v4OH7Ycv1MHPLWnVIjvWAGuckkjy4Dma zsbkaZrEhObNRvVDlyQUQp+m+GwF3siH25aCs2MRjAeVegDXTEQY8gy+N/SzhNqf9UZP dLVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=NZgLPXEkc9lMGGHYkgWyY8ApMF2V5XfGzLDUm/ogFRU=; b=ZpQLZrLyi0FNgyHZRHiWJ+ZOlntsHJ7WdjmnKyrKX+xsGV69Jt5kufIupbwhO6AxNF mmNPOs8mNEWn1uL051jKjEX17BJTOStefi3XKGrgX0QVrAx3e7HcCmFyhClPQFmQXmg4 GLt/wfvo6qlgaK86ZTpS2ynSKcaeBbE/3PZBXZuarYmKL1UBw8chJEbiDNA4nd7eDFAF CzI2E2lf58bPvBHv91Vb9JNTgGrQuBVfCb674u2X68vAo+C2b1zq+1IpidDYZ3o4z+sP 1kpztMXiWpEVWDTdqY1Ckc1b8FoneAxd1Vl0Wj0XT/usduNVJk/TFJW4GGkRjEMFens3 h3pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="vKL/xFYz"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nc9-20020a1709071c0900b0086d6cc19f9bsi9296838ejc.166.2023.01.16.06.50.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 06:50:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="vKL/xFYz"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D34F3854398 for ; Mon, 16 Jan 2023 14:49:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D34F3854398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673880573; bh=NZgLPXEkc9lMGGHYkgWyY8ApMF2V5XfGzLDUm/ogFRU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=vKL/xFYznGuaUVtPKhzV4M9mXtdXAiZTddth0spvM/4uA4ctJIx+RAuhyQlf0Qx6c g6VTk4j9xip6guzNZZhWk5Qzx/kRaaMO67l/+2mGc8jezdXsJTRtO4uma/9c+fVE9k Oj24rr3VAFYcCqL5wY/aMn0iNHJ/hv9+Gpsf0S5A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 41172385843E for ; Mon, 16 Jan 2023 14:48:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41172385843E Received: by mail-wm1-x32e.google.com with SMTP id o15so20144775wmr.4 for ; Mon, 16 Jan 2023 06:48:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NZgLPXEkc9lMGGHYkgWyY8ApMF2V5XfGzLDUm/ogFRU=; b=bIaOZrYArW0SzyJfnWrVir/CUD7YLJpVKj+yRK1OELlrwPp1zHw6jPbWqkNqwDhOLn ATFioWF/YiSeayijXFWsuKnfqMHi8T6hvRqLZwU8bXT9xGeixRHsxBZ5lhzwJZLfKPYG Ckr3PtPf3C5qAkUqId4YupCHJaMPrm2tk4puYTVUU3OAmUfgXYEm4R8dwkbUgT1Q5rUv tr7oy9DADk3sMAtsnmW+Gads8tEmQ99H2Dqqz++mV1nlfUQ8HImFQHLgWSTdcPWQ1Xpc +VTWwzIhMqd7U6LSEz23KBXfMxT3lL1AfKQ44VPghTn7LckouYMEfC4gQaEkLl1lZk+x XAYw== X-Gm-Message-State: AFqh2krpnr2YsLnPnCioXpsOxo6u6TJG7ZdD0/CueOLFbpmVv6u4cgWh OmCgejMVMf5vBd93bRxZPsuU6ZP6cw0m2FX3 X-Received: by 2002:a05:600c:539a:b0:3d9:efe8:a42d with SMTP id hg26-20020a05600c539a00b003d9efe8a42dmr23685143wmb.21.1673880524105; Mon, 16 Jan 2023 06:48:44 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id he5-20020a05600c540500b003d9ed40a512sm33292630wmb.45.2023.01.16.06.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 06:48:43 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Lift restriction on optimization of aliased objects Date: Mon, 16 Jan 2023 15:48:41 +0100 Message-Id: <20230116144841.3171334-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755191038218051382?= X-GMAIL-MSGID: =?utf-8?q?1755191038218051382?= From: Eric Botcazou It turns out that the only blocking case is an aliased object whose nominal subtype is an unconstrained array because the bounds must be allocated. gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Also optimize aliased objects if their nominal subtype is not an unconstrained array. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch3.adb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 536ae0c36e4..c866a9c40f5 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -7965,10 +7965,10 @@ package body Exp_Ch3 is Is_Entity_Name (Original_Node (Obj_Def)) - -- The aliased case has to be excluded because the expression - -- will not be aliased in the general case. + -- Nor if it is effectively an unconstrained declaration - and then not Aliased_Present (N) + and then not (Is_Array_Type (Typ) + and then Is_Constr_Subt_For_UN_Aliased (Typ)) -- We may use a renaming if the initializing expression is a -- captured function call that meets a few conditions.