From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Improve efficiency of scope stack restoration
Date: Fri, 4 Nov 2022 14:56:28 +0100 [thread overview]
Message-ID: <20221104135628.85893-1-poulhies@adacore.com> (raw)
From: Piotr Trojanek <trojanek@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
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
--
2.34.1
reply other threads:[~2022-11-04 13:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221104135628.85893-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).