From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 731A738555AC for ; Mon, 7 Nov 2022 08:41:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 731A738555AC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42f.google.com with SMTP id j15so15046236wrq.3 for ; Mon, 07 Nov 2022 00:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WgLm+aVhAraqFGwhHnho9snRcYEK5IFVj8K5+jPnwQs=; b=NwWpwuB05U4UO56NnHJXTyu6LEQWsIkUaTSsdAwk3pIerD/n122AUPehXycgFigd6u +F1VIvsMRhMOsLTweyMHTdd5D/cWGtbaCibG6ijf157cdGQMiz6Du52K7VhTbeK1zb52 Zvqzsy307fgY9JZz5qFNMlzYW8d40whhabyvGDOYFHZHjX/cJTlPWIj8rQBJAEppsEde LM5eh3qfoHpHEMedTtbX28Ganf0jS38adKdY6PFw4+udS8nZDqeV6v8qq4w16bPSe+uy 6kDjjGp8BAs7o5vKiBWoi33OnTj4auxnjY4+7R7O2EKqNUP7QuPoR3qKsOaywed99KGH Rtww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WgLm+aVhAraqFGwhHnho9snRcYEK5IFVj8K5+jPnwQs=; b=JjQZtV6kusmTESdm9LIUN0F4th0Ym3MVXiibUQJVXfFKt6Ib6YdP4/ZbJSL2mP8d9G 2NiEecj3SA4sb3McIdKsDeTgXZitVNyfG3rznBViQPPpx7rNH9DYMPV7mJaCEjXZei8Z U2Db0DLGzYdLZS5auYGG1mofYV9/KjKtmBekmCRoC3Wg+HZygE3quxMZt7X4K/jiWFlH QB7fpw1s6pbWQWCPIPgql9HTflId1nzz+NeBsPargu/MGPHyz3/azdL1aKSwnkpEtNfP qaZNDnxndm0GTFkJbj89oJJkGBTNBphW4/rMLPHcCgRFnBbMJKi9bWpjgYcbvbfDa+wD c+Ng== X-Gm-Message-State: ACrzQf3LWoE+PA5JvDHC5clGS4OI5/1KyqqkzA2hv8QWpY4lVMo3J0PD FCqKHvIeYij1wGjFr2V/eEkFt8yjtSkiqw== X-Google-Smtp-Source: AMsMyM5thXOc53k33VUNaYR7nkji8z776H4RwHusbYihwuhSz2Hoon4ahTltnNmqr81StoUwM5BZMw== X-Received: by 2002:adf:ea88:0:b0:238:e63c:1f4a with SMTP id s8-20020adfea88000000b00238e63c1f4amr12822166wrm.446.1667810477134; Mon, 07 Nov 2022 00:41:17 -0800 (PST) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id m8-20020a05600c4f4800b003c64c186206sm7624682wmq.16.2022.11.07.00.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:41:16 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Inline composite node kind AST queries Date: Mon, 7 Nov 2022 09:41:14 +0100 Message-Id: <20221107084114.151758-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Piotr Trojanek 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