From patchwork Fri Nov 4 13:57:52 2022 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: 15547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp421464wru; Fri, 4 Nov 2022 07:03:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74og0LIkUH6uZy4Y+ky+tzYWQ8eBcpLEALe37FsjjghtuY0rfIrQ0X95tBsx17ddM2zuBt X-Received: by 2002:a17:907:6e1b:b0:78e:15a3:5be6 with SMTP id sd27-20020a1709076e1b00b0078e15a35be6mr34757700ejc.750.1667570624527; Fri, 04 Nov 2022 07:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667570624; cv=none; d=google.com; s=arc-20160816; b=UPZd4SDeof9MBw4Cyf9M7z5SV1oeAq0XEt/n+cSQX1jAiv4NMTaFihNvo5DC2z96r2 zZVZOvAaGBe621OnWVunponRqdQSu8HZ5p0VMrE4JcpxBM/90AxYNcApEbLfGaG/SAOZ LhFbvbeWSJUQ4swDCob0ZRAX17+U1Tro7mwJK5nJ+4aaV8Vva++bdicN4p7uHeXtrsqN 8P0f2oYz90hcwkifoa5hNi/r9a31HHCntjmRJyXiZsPU4w5V/MfB6gvLZC2DMJ6ZFVKb d+hYdyrCTLDC5TXHQWUauAsiI+pO65wVk6qoV5mGOL4Fl1zQi+/bcRQbHJ+CiEb4Zzxd 1riw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=kpJQGcLuB5dZPJ75O7OK51mozXlns14GR+gViU+gTkI=; b=hU9zFIAWPPnssXM11hY/ROvctdyPGpPBTGGp2TmM76g1F89l8APbkSqSpgp3oLTQaD Wlt7HA2uAm9AAxbgjs1qDViUiE4cwcJcCa+DcyA1UvobjnUynhMZ8T0DqXJw9lg9wuQX 2QP7HmMFATb4lJsL/XLP0SJBqcZJ0EiB+tk28Yv2yT+d/6li6fusrgJmab8Th8ulmSZ+ fUElgAZIxN6GonNed8qksC3yXgeoSP50hbmzkfM0aLp5UJHjF/Fw0dGvEZ0cBfzK/EpX iHm6y2JCOl8BtOZhGAGov7fAJgwmRcbF+1R63Xvu99/bv+7/Ie5nDEsZbsotyKQVZRei W+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZI12+M6p; 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 qo10-20020a170907212a00b0078e15c30a6csi1201837ejb.559.2022.11.04.07.03.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 07:03:44 -0700 (PDT) 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=ZI12+M6p; 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 1C8CE3885C26 for ; Fri, 4 Nov 2022 13:59:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C8CE3885C26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667570391; bh=kpJQGcLuB5dZPJ75O7OK51mozXlns14GR+gViU+gTkI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZI12+M6pgOz1OpjACAXVIv0ItH8xEQI+HlSW9GNV1e+vD1RLKEhtcXAK3fyHdDBJP HMnJzHk8sCA1owI1q4hckVlglleyI0Sk8tNMRNrqpJRRWmjaxgq4ccpQ1GfRlCtL9R GH7PpNXCu124JXrGROoGCcQCNH178m/EsAZYCFoo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 7CDED385803D for ; Fri, 4 Nov 2022 13:57:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CDED385803D Received: by mail-wm1-x32c.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so3238115wmg.2 for ; Fri, 04 Nov 2022 06:57:57 -0700 (PDT) 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=kpJQGcLuB5dZPJ75O7OK51mozXlns14GR+gViU+gTkI=; b=mooo1m/RcEkcYt9zVX/HqyT2mYBiPMYvzEMc10HT05wTnm5bc3M0H94w1XRFxXSDSV nk9nrmqn9mGteKK//iyTi1LQUDfhwrWgX7701HKb4PWJoPtnWB/CBa8PvKAT/0W/xZCu IUNf2jCcejjehFa1sUmwxYfa0LWsppla/RWlwSTTQF5oWhGM4Bq04IfcVd/QztJ6U6ny kTE8p+mz2+d81CjuhKyXz6OKZfaYdzmK0eGT2qfjfRJctHhn6uefGlQ7EGX0g8UOcPHF BRjpy5z6yElKQ9w6MwanacK2JZfE2mejsO9di7VnYQF317QXytV/7VmWVXjZuM1JHkWf CcYg== X-Gm-Message-State: ACrzQf2JjkIqcyBKWmcHv23wv0W6swGnTM4SaDCvcFhqjkq11tLNckkZ VWcoQztjD9fkCtW2oUT/7w75v7M834RtXw== X-Received: by 2002:a05:600c:1d2a:b0:3cf:7332:946 with SMTP id l42-20020a05600c1d2a00b003cf73320946mr17997765wms.126.1667570276256; Fri, 04 Nov 2022 06:57:56 -0700 (PDT) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id i2-20020a05600c354200b003c71358a42dsm4131363wmq.18.2022.11.04.06.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:57:55 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] ada: Cleanup clearing flags on package variables Date: Fri, 4 Nov 2022 14:57:52 +0100 Message-Id: <20221104135752.86633-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 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?= Cc: Piotr Trojanek 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?1748574535207468254?= X-GMAIL-MSGID: =?utf-8?q?1748574535207468254?= From: Piotr Trojanek When killing flags on assignable entities we iterated from First_Entity and then again from First_Private_Entity. This second iteration was unnecessary, because the entity chain that starts with First_Entity contains all entities, including the private ones. This is just a performance improvement; the behavior is unchanged. gcc/ada/ * sem_ch7.adb (Clear_Constants): Only iterate from First_Entity through Next_Entity; only examine variables because packages have no assignable formal parameters. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch7.adb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 5c347bd8b4f..77d1b38b827 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1317,11 +1317,10 @@ package body Sem_Ch7 is -- private_with_clauses, and remove them at the end of the nested -- package. - procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id); - -- Clears constant indications (Never_Set_In_Source, Constant_Value, and - -- Is_True_Constant) on all variables that are entities of Id, and on - -- the chain whose first element is FE. A recursive call is made for all - -- packages and generic packages. + procedure Clear_Constants (Id : Entity_Id); + -- Clears constant indications (Never_Set_In_Source, Constant_Value, + -- and Is_True_Constant) on all variables that are entities of Id. + -- A recursive call is made for all packages and generic packages. procedure Generate_Parent_References; -- For a child unit, generate references to parent units, for @@ -1352,7 +1351,7 @@ package body Sem_Ch7 is -- Clear_Constants -- --------------------- - procedure Clear_Constants (Id : Entity_Id; FE : Entity_Id) is + procedure Clear_Constants (Id : Entity_Id) is E : Entity_Id; begin @@ -1368,9 +1367,9 @@ package body Sem_Ch7 is -- package can contain a renaming declaration to itself, and such -- renamings are generated automatically within package instances. - E := FE; + E := First_Entity (Id); while Present (E) and then E /= Id loop - if Is_Assignable (E) then + if Ekind (E) = E_Variable then Set_Never_Set_In_Source (E, False); Set_Is_True_Constant (E, False); Set_Current_Value (E, Empty); @@ -1382,8 +1381,7 @@ package body Sem_Ch7 is end if; elsif Is_Package_Or_Generic_Package (E) then - Clear_Constants (E, First_Entity (E)); - Clear_Constants (E, First_Private_Entity (E)); + Clear_Constants (E); end if; Next_Entity (E); @@ -2009,8 +2007,7 @@ package body Sem_Ch7 is if Is_Library_Level_Entity (Id) or else Is_Generic_Instance (Id) then - Clear_Constants (Id, First_Entity (Id)); - Clear_Constants (Id, First_Private_Entity (Id)); + Clear_Constants (Id); end if; -- Output relevant information as to why the package requires a body.