From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32e.google.com with SMTP id o15so20144775wmr.4 for ; Mon, 16 Jan 2023 06:48:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NZgLPXEkc9lMGGHYkgWyY8ApMF2V5XfGzLDUm/ogFRU=; b=Y1i/788vp7+f0iXcH0FikDeTOf1bNmonUakByUTeV8zfjeWvzikrJPWiFHJU77o2fw sXinrI6xatIJfvbwdZFFlZZxVUDDpYgNbduDz5yGf60QzM3bzVQIBIs2xs9i52K+XdgG ncMC/vFxPvDz6notXlz4cja8pNYtefefra8jKDBDA9RTZXG8Hhkc/PtqTDoBqIVhoUSx op1OfdpcV9R8STDOUjJKwR4/tArN0ljpTsc2h4LmM6cM9pXe0YCnNPotummyZe8Cg3e+ 5xav9vme0Wom7NdGQCjwlNNzlrxNTBOmCJuSW8uqzjhzALUZS0p+tEk+gqXEKp7fR0HP O+tA== 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-Google-Smtp-Source: AMrXdXvzFEDy/qfjNzWvVyaU0FFppl0EDAuPs+fgt9EZr9dTrCwU82EQcIBZpR1ibyOmW73ssbkCsA== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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. -- 2.34.1