public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3744] ada: Fix performance regression related to references in Refined_State Date: Mon, 7 Nov 2022 08:40:17 +0000 (GMT) [thread overview] Message-ID: <20221107084045.6BE753858414@sourceware.org> (raw) https://gcc.gnu.org/g:dc3208e698b2f424d892d3c9e5d5562ccde9e4cf commit r13-3744-gdc3208e698b2f424d892d3c9e5d5562ccde9e4cf Author: Piotr Trojanek <trojanek@adacore.com> Date: Mon Oct 17 22:08:37 2022 +0200 ada: Fix performance regression related to references in Refined_State Recently added call to In_Pragma_Expression caused a performance regression. It might require climbing syntax trees of arbitrarily deep expressions, while previously references within pragmas were detected in bounded time. This patch restores the previous efficiency. However, while the original code only detected references directly within pragma argument associations, now we also detect references inside aggregates, e.g. like those in pragma Refined_State. gcc/ada/ * sem_prag.adb (Non_Significant_Pragma_Reference): Detect references with aggregates; only assign local variables Id and C when necessary. Diff: --- gcc/ada/sem_prag.adb | 56 +++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index f33d858062d..2a3aca85a79 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -31719,43 +31719,45 @@ package body Sem_Prag is -- Start of processing for Non_Significant_Pragma_Reference begin - P := Parent (N); - - if Nkind (P) /= N_Pragma_Argument_Association then + -- Reference might appear either directly as expression of a pragma + -- argument association, e.g. pragma Export (...), or within an + -- aggregate with component associations, e.g. pragma Refined_State + -- ((... => ...)). - -- References within pragma Refined_State are not significant. They - -- can't be recognized using pragma argument number, because they - -- appear inside refinement clauses that rely on aggregate syntax. + P := Parent (N); + loop + case Nkind (P) is + when N_Pragma_Argument_Association => + exit; + when N_Aggregate | N_Component_Association => + P := Parent (P); + when others => + return False; + end case; + end loop; - if In_Pragma_Expression (N, Name_Refined_State) then - return True; - end if; + AN := Arg_No; + if AN = 0 then return False; + end if; - else - Id := Get_Pragma_Id (Parent (P)); - C := Sig_Flags (Id); - AN := Arg_No; + Id := Get_Pragma_Id (Parent (P)); + C := Sig_Flags (Id); - if AN = 0 then + case C is + when -1 => return False; - end if; - - case C is - when -1 => - return False; - when 0 => - return True; + when 0 => + return True; - when 92 .. 99 => - return AN < (C - 90); + when 92 .. 99 => + return AN < (C - 90); - when others => - return AN /= C; - end case; - end if; + when others => + return AN /= C; + end case; end Is_Non_Significant_Pragma_Reference; ------------------------------
reply other threads:[~2022-11-07 8:40 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=20221107084045.6BE753858414@sourceware.org \ --to=dkm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).