public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Inline composite node kind AST queries
Date: Mon,  7 Nov 2022 09:41:14 +0100	[thread overview]
Message-ID: <20221107084114.151758-1-poulhies@adacore.com> (raw)

From: Piotr Trojanek <trojanek@adacore.com>

Queries that ultimately examine the same field of an AST
node (e.g. Nkind) are visibly more efficient when inlined.

In particular, routines Is_Body_Or_Package_Declaration and Is_Body can
apparently be inlined into a single Nkind membership test.

This patch fixes some of the performance lost with the recent changes,
which increased the number of calls to Is_Body_Or_Package_Declaration
(as it is typically used to prevent AST search from climbing too far).
However, it should be generally beneficial to inline routines like this.

gcc/ada/

	* sem_aux.ads (Is_Body): Annotate with Inline.
	* sem_util.ads (Is_Body_Or_Package_Declaration): Likewise.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_aux.ads  | 2 +-
 gcc/ada/sem_util.ads | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_aux.ads b/gcc/ada/sem_aux.ads
index 66cbcfbb97c..004aadbd704 100644
--- a/gcc/ada/sem_aux.ads
+++ b/gcc/ada/sem_aux.ads
@@ -279,7 +279,7 @@ package Sem_Aux is
    --  or subtype. This is true if Suppress_Initialization is set either for
    --  the subtype itself, or for the corresponding base type.
 
-   function Is_Body (N : Node_Id) return Boolean;
+   function Is_Body (N : Node_Id) return Boolean with Inline;
    --  Determine whether an arbitrary node denotes a body
 
    function Is_By_Copy_Type (Ent : Entity_Id) return Boolean;
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 5c08cb8b9ab..2126beda510 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -1881,7 +1881,8 @@ package Sem_Util is
    function Is_Attribute_Update (N : Node_Id) return Boolean;
    --  Determine whether node N denotes attribute 'Update
 
-   function Is_Body_Or_Package_Declaration (N : Node_Id) return Boolean;
+   function Is_Body_Or_Package_Declaration (N : Node_Id) return Boolean
+     with Inline;
    --  Determine whether node N denotes a body or a package declaration
 
    function Is_Bounded_String (T : Entity_Id) return Boolean;
-- 
2.34.1


                 reply	other threads:[~2022-11-07  8:41 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=20221107084114.151758-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).