From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 28BBC385842B; Fri, 4 Nov 2022 13:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28BBC385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667570032; bh=bzX94jbmXAHqU4E+Vw4lc6tHIH2/7s1iQw2Y5473eeg=; h=From:To:Subject:Date:From; b=dfztJ7snKqNei3hqW0Do9QXjtpnSQy2vQZmq50IPyerlZIDgRrPjYH5gVjBTVpiKd pu+AfoukPLZDdWzNR8RdvOICj10r5aOI6MYVqbZfC1o9NeNx6hd7bY8ZGeYvysASEm zJa/eNg3g/f1OF1JDoN6+Ysin+N07Ke1ZeQYAUoc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3661] ada: Improve efficiency of scope stack restoration X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 41d5a493ede13740a30b4a66cc666ac4daa92fb7 X-Git-Newrev: 533d79ac93b7757060a901df055575320e2ca422 Message-Id: <20221104135352.28BBC385842B@sourceware.org> Date: Fri, 4 Nov 2022 13:53:52 +0000 (GMT) List-Id: https://gcc.gnu.org/g:533d79ac93b7757060a901df055575320e2ca422 commit r13-3661-g533d79ac93b7757060a901df055575320e2ca422 Author: Piotr Trojanek Date: Thu Oct 6 23:42:46 2022 +0200 ada: Improve efficiency of scope stack restoration We save/restore visibility by setting the Is_Immediately_Visible flag and appending entities to / removing them from the tail of an element list. However, the Is_Immediately_Visible flag can be restored in any order, while the element list is singly-linked and removal from the tail is inefficient. This change removes a performance hot spot, which accounted for up to 10% of compilation time of complex applications (e.g. QGen), at least as measured on GNAT built with profiling support. gcc/ada/ * sem_ch8.adb (Restore_Scope_Stack): Remove elements from the head and not the tail of an element list. Diff: --- gcc/ada/sem_ch8.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index c4812e2a563..e555de915e6 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -9717,10 +9717,10 @@ package body Sem_Ch8 is -- we saved (we use Remove, since this list will not be used again). loop - Elmt := Last_Elmt (List); + Elmt := First_Elmt (List); exit when Elmt = No_Elmt; Set_Is_Immediately_Visible (Node (Elmt)); - Remove_Last_Elmt (List); + Remove_Elmt (List, Elmt); end loop; -- Restore use clauses