From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id B10B83858403; Mon, 7 Nov 2022 08:39:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B10B83858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810398; bh=cPGFSgx6h8SQ5ESXGBm/wC68t3TIIDRhJoJGu6vDgsM=; h=From:To:Subject:Date:From; b=Hm4wJeH5JKUf77jcz+ELxesIHizJNDGI+BgVIKlsNmguV9EnZI935bUkmwxrt5Se7 Oov6pC1KsOsMv+2zSjlXqXjXZqn4qv6TJl0PPQ8oK0w0nAczhzij3p4Rl4Qld5Uc+g MIzHP3WuUNxReg4V82vE3k+GdF7oYLXeSuTkFcUw= 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-3741] ada: Inline composite node kind AST queries X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 27345558cce16e849884f5d1d4dd7d88974bb724 X-Git-Newrev: 9b07c1752b9bf49143a41c810e2db86f633fdb1c Message-Id: <20221107083958.B10B83858403@sourceware.org> Date: Mon, 7 Nov 2022 08:39:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9b07c1752b9bf49143a41c810e2db86f633fdb1c commit r13-3741-g9b07c1752b9bf49143a41c810e2db86f633fdb1c Author: Piotr Trojanek Date: Mon Oct 17 16:28:20 2022 +0200 ada: Inline composite node kind AST queries 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. Diff: --- 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;