From patchwork Mon May 9 12:45:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1628593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=OgVItRXL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kxgrc5Jftz9sGD for ; Mon, 9 May 2022 22:45:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 742203888C43 for ; Mon, 9 May 2022 12:45:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 7D6253857361 for ; Mon, 9 May 2022 12:45:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D6253857361 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-x730.google.com with SMTP id v11so193783qkf.1 for ; Mon, 09 May 2022 05:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:content-language:to :from:subject; bh=3rNBUy0ztmRBWO+4l7bNxLFRUrJl9R4jR+nbqEJFnZE=; b=OgVItRXLyquzP3bfmOI2MrEuUJFBuU7sxGTYSu2fr52fUjy5NPL3/ell5dxZ1TIApt sozUlRIH8xhbMvZI82ptHQOfclLydIjkZ7asDFvYp1V9pdOSMLqFs5EHUBblQeIiGCZ3 pgPytbNOq/+o8uosRT6Lo1kaGIwlHblodQl9daSad86gWJI8c0s57lDe/Rf2GQvfbjA+ Tg8CA2Avtn6QzNXix7hR//1eYOPt8Bp+TpuRj6BChDEL9YPEegzw5g4HTbuSMt1G23VC AlVIv3ZiNYAP44iB9A0VAo9gfYXwPU35EJgGFBNWowkCJUuRXkyg4qgb7VnroQND2INZ WHIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :content-language:to:from:subject; bh=3rNBUy0ztmRBWO+4l7bNxLFRUrJl9R4jR+nbqEJFnZE=; b=cxSYkvp3N6BLXkSwCqD/MKLUZC64nbDD8rJqWOe65qLNdzJ9VIm4tbXf373XJdzXUB dHNLzb7aq/9ZXhlm7K15LrXTV/EePOm9B5jWoidebwNo054HzBu7IveZ4w9rkbdjh75a /knlIdrf2vVogn+YIT4VFuTzdBxhBXHmKfGb/YU7uSPSe5iZHLTq9I7AsFKZODMDiQM0 EV9D8ygrYxhQL8mmPxt/Tz2N1lq9fLZ20UFSbt+VKNdLNNnj5NKpxsPmCcSvJa485kLj v0YGlqDSMrP8+LFABnevzZiLXtnJjlx+BSgQm7W0ndnqXR17og8RTX5W736lIMdzZcOC rvYQ== X-Gm-Message-State: AOAM531f0hviCiL7W/X933kPKweb39bgMZNMK/w7b5nnA2pFpSVUy2Gw S+FyjxUGSnL+ftjHdq26N3TQeTEbQeQ= X-Google-Smtp-Source: ABdhPJygzu9oTrYOS9yejVfV2dFWNiLYM7krLaSUOnxs+uqP9p7ebySFNmWxHr+HkDOASYjbFSBQDw== X-Received: by 2002:a05:620a:430b:b0:67e:85d1:f53f with SMTP id u11-20020a05620a430b00b0067e85d1f53fmr11412823qko.43.1652100336579; Mon, 09 May 2022 05:45:36 -0700 (PDT) Received: from ?IPV6:2620:10d:c0a3:1407:d7d7:a56:877a:6c90? ([2620:10d:c091:500::30ca]) by smtp.googlemail.com with ESMTPSA id f3-20020ac84703000000b002f39b99f689sm7558676qtp.35.2022.05.09.05.45.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 May 2022 05:45:35 -0700 (PDT) Message-ID: <62449168-11b9-b383-d492-4f2e07aa5f51@acm.org> Date: Mon, 9 May 2022 08:45:34 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Content-Language: en-US To: GCC Patches From: Nathan Sidwell Subject: [c++][NFC] Rename Attached to Keyed X-Spam-Status: No, score=-3039.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" With modules, certain decls are 'scoped' with another decl. I chose the name 'attached', but that has become something specific in the modules context, so is no longer a good name. The alternative name I considered was 'keyed', but we already had the concept of a key virtual function (from the ABI), which is why I went with 'attached'. However, I think 'keyed' is the less worse name. I think there's less chance of confusion. nathan From c0718dc18559912e6228aaabae0c34ff12b63288 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 9 May 2022 04:36:30 -0700 Subject: [PATCH] [c++][NFC] Rename Attached to Keyed With modules, certain decls are 'scoped' with another decl. I chose the name 'attached', but that has become something specific in the modules context, so is no longer a good name. The alternative name I considered was 'keyed', but we already had the concept of a key virtual function (from the ABI), which is why I went with 'attached'. However, I think 'keyed' is the less worse name. I think there's less chance of confusion. --- gcc/cp/cp-tree.h | 10 ++++---- gcc/cp/lambda.cc | 2 +- gcc/cp/lex.cc | 4 +-- gcc/cp/module.cc | 64 ++++++++++++++++++++++++------------------------ 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 663fe7a20fc..10ecab76082 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1734,9 +1734,9 @@ check_constraint_info (tree t) (DECL_LANG_SPECIFIC (DECL_MODULE_CHECK (NODE))->u.base.module_entity_p) /* DECL that has attached decls for ODR-relatedness. */ -#define DECL_MODULE_ATTACHMENTS_P(NODE) \ +#define DECL_MODULE_KEYED_DECLS_P(NODE) \ (DECL_LANG_SPECIFIC (TREE_CHECK2(NODE,FUNCTION_DECL,VAR_DECL))\ - ->u.base.module_attached_p) + ->u.base.module_keyed_decls_p) /* Whether this is an exported DECL. Held on any decl that can appear at namespace scope (function, var, type, template, const or @@ -2836,8 +2836,8 @@ struct GTY(()) lang_decl_base { unsigned module_import_p : 1; /* from an import */ unsigned module_entity_p : 1; /* is in the entitity ary & hash. */ - /* VAR_DECL or FUNCTION_DECL has attached decls. */ - unsigned module_attached_p : 1; + /* VAR_DECL or FUNCTION_DECL has keyed decls. */ + unsigned module_keyed_decls_p : 1; /* 12 spare bits. */ }; @@ -7196,7 +7196,7 @@ extern unsigned get_importing_module (tree, bool = false) ATTRIBUTE_PURE; /* Where current instance of the decl got declared/defined/instantiated. */ extern void set_instantiating_module (tree); extern void set_defining_module (tree); -extern void maybe_attach_decl (tree ctx, tree decl); +extern void maybe_key_decl (tree ctx, tree decl); extern void mangle_module (int m, bool include_partition); extern void mangle_module_fini (); diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc index afac53b6d7c..0a9f0f8f310 100644 --- a/gcc/cp/lambda.cc +++ b/gcc/cp/lambda.cc @@ -1431,7 +1431,7 @@ record_lambda_scope (tree lambda) { tree closure = LAMBDA_EXPR_CLOSURE (lambda); gcc_checking_assert (closure); - maybe_attach_decl (lambda_scope, TYPE_NAME (closure)); + maybe_key_decl (lambda_scope, TYPE_NAME (closure)); } } diff --git a/gcc/cp/lex.cc b/gcc/cp/lex.cc index 739f0890e01..784debcd705 100644 --- a/gcc/cp/lex.cc +++ b/gcc/cp/lex.cc @@ -1008,8 +1008,8 @@ cxx_dup_lang_specific_decl (tree node) (module_purview_p still does). */ ld->u.base.module_entity_p = false; ld->u.base.module_import_p = false; - ld->u.base.module_attached_p = false; - + ld->u.base.module_keyed_decls_p = false; + if (GATHER_STATISTICS) { tree_node_counts[(int)lang_decl] += 1; diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 18dabfcc9ac..6126316a6a0 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -2697,11 +2697,11 @@ pending_map_t *pending_table; completed. */ vec *post_load_decls; -/* Some entities are attached to another entitity for ODR purposes. +/* Some entities are keyed to another entitity for ODR purposes. For example, at namespace scope, 'inline auto var = []{};', that - lambda is attached to 'var', and follows its ODRness. */ -typedef hash_map> attached_map_t; -static attached_map_t *attached_table; + lambda is keyed to 'var', and follows its ODRness. */ +typedef hash_map> keyed_map_t; +static keyed_map_t *keyed_table; /********************************************************************/ /* Tree streaming. The tree streaming is very specific to the tree @@ -2766,7 +2766,7 @@ enum merge_kind MK_partial, MK_enum, /* Found by CTX, & 1stMemberNAME. */ - MK_attached, /* Found by attachee & index. */ + MK_keyed, /* Found by key & index. */ MK_friend_spec, /* Like named, but has a tmpl & args too. */ MK_local_friend, /* Found by CTX, index. */ @@ -5533,7 +5533,7 @@ trees_out::lang_decl_bools (tree t) that's the GM purview, so not what the importer will mean */ WB (lang->u.base.module_purview_p && !header_module_p ()); if (VAR_OR_FUNCTION_DECL_P (t)) - WB (lang->u.base.module_attached_p); + WB (lang->u.base.module_keyed_decls_p); switch (lang->u.base.selector) { default: @@ -5603,7 +5603,7 @@ trees_in::lang_decl_bools (tree t) RB (lang->u.base.dependent_init_p); RB (lang->u.base.module_purview_p); if (VAR_OR_FUNCTION_DECL_P (t)) - RB (lang->u.base.module_attached_p); + RB (lang->u.base.module_keyed_decls_p); switch (lang->u.base.selector) { default: @@ -7701,11 +7701,11 @@ trees_out::decl_value (tree decl, depset *dep) if (VAR_OR_FUNCTION_DECL_P (inner) && DECL_LANG_SPECIFIC (inner) - && DECL_MODULE_ATTACHMENTS_P (inner) + && DECL_MODULE_KEYED_DECLS_P (inner) && !is_key_order ()) { - /* Stream the attached entities. */ - auto *attach_vec = attached_table->get (inner); + /* Stream the keyed entities. */ + auto *attach_vec = keyed_table->get (inner); unsigned num = attach_vec->length (); if (streaming_p ()) u (num); @@ -7998,12 +7998,12 @@ trees_in::decl_value () if (VAR_OR_FUNCTION_DECL_P (inner) && DECL_LANG_SPECIFIC (inner) - && DECL_MODULE_ATTACHMENTS_P (inner)) + && DECL_MODULE_KEYED_DECLS_P (inner)) { /* Read and maybe install the attached entities. */ bool existed; - auto &set = attached_table->get_or_insert (STRIP_TEMPLATE (existing), - &existed); + auto &set = keyed_table->get_or_insert (STRIP_TEMPLATE (existing), + &existed); unsigned num = u (); if (is_new == existed) set_overrun (); @@ -10200,9 +10200,9 @@ trees_out::get_merge_kind (tree decl, depset *dep) = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR (TREE_TYPE (decl)))) if (TREE_CODE (scope) == VAR_DECL - && DECL_MODULE_ATTACHMENTS_P (scope)) + && DECL_MODULE_KEYED_DECLS_P (scope)) { - mk = MK_attached; + mk = MK_keyed; break; } @@ -10492,13 +10492,13 @@ trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner, } break; - case MK_attached: + case MK_keyed: { gcc_checking_assert (LAMBDA_TYPE_P (TREE_TYPE (inner))); tree scope = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR (TREE_TYPE (inner))); gcc_checking_assert (TREE_CODE (scope) == VAR_DECL); - auto *root = attached_table->get (scope); + auto *root = keyed_table->get (scope); unsigned ix = root->length (); /* If we don't find it, we'll write a really big number that the reader will ignore. */ @@ -10506,7 +10506,7 @@ trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner, if ((*root)[ix] == inner) break; - /* Use the attached-to decl as the 'name'. */ + /* Use the keyed-to decl as the 'name'. */ name = scope; key.index = ix; } @@ -10773,12 +10773,12 @@ trees_in::key_mergeable (int tag, merge_kind mk, tree decl, tree inner, gcc_unreachable (); case NAMESPACE_DECL: - if (mk == MK_attached) + if (mk == MK_keyed) { if (DECL_LANG_SPECIFIC (name) && VAR_OR_FUNCTION_DECL_P (name) - && DECL_MODULE_ATTACHMENTS_P (name)) - if (auto *set = attached_table->get (name)) + && DECL_MODULE_KEYED_DECLS_P (name)) + if (auto *set = keyed_table->get (name)) if (key.index < set->length ()) { existing = (*set)[key.index]; @@ -18566,10 +18566,10 @@ set_originating_module (tree decl, bool friend_p ATTRIBUTE_UNUSED) DECL_MODULE_EXPORT_P (decl) = true; } -/* DECL is attached to ROOT for odr purposes. */ +/* DECL is keyed to CTX for odr purposes. */ void -maybe_attach_decl (tree ctx, tree decl) +maybe_key_decl (tree ctx, tree decl) { if (!modules_p ()) return; @@ -18581,14 +18581,14 @@ maybe_attach_decl (tree ctx, tree decl) gcc_checking_assert (DECL_NAMESPACE_SCOPE_P (ctx)); - if (!attached_table) - attached_table = new attached_map_t (EXPERIMENT (1, 400)); + if (!keyed_table) + keyed_table = new keyed_map_t (EXPERIMENT (1, 400)); - auto &vec = attached_table->get_or_insert (ctx); + auto &vec = keyed_table->get_or_insert (ctx); if (!vec.length ()) { retrofit_lang_decl (ctx); - DECL_MODULE_ATTACHMENTS_P (ctx) = true; + DECL_MODULE_KEYED_DECLS_P (ctx) = true; } vec.safe_push (decl); } @@ -18898,8 +18898,8 @@ direct_import (module_state *import, cpp_reader *reader) if (import->loadedness < ML_LANGUAGE) { - if (!attached_table) - attached_table = new attached_map_t (EXPERIMENT (1, 400)); + if (!keyed_table) + keyed_table = new keyed_map_t (EXPERIMENT (1, 400)); import->read_language (true); } @@ -20004,9 +20004,9 @@ fini_modules () delete pending_table; pending_table = NULL; - /* Or any attachments -- Let it go! */ - delete attached_table; - attached_table = NULL; + /* Or any keys -- Let it go! */ + delete keyed_table; + keyed_table = NULL; /* Allow a GC, we've possibly made much data unreachable. */ ggc_collect (); -- 2.30.2