From patchwork Wed Jun 29 16:37:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1650232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=m8Y2hSc5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4LY6b74g6Qz9s0w for ; Thu, 30 Jun 2022 02:38:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73122384D14A for ; Wed, 29 Jun 2022 16:38:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73122384D14A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656520686; bh=+Aj013EWhfMErMN1FzT2VIR18U2qUc9v2+ZrMaB0BZ0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=m8Y2hSc5222eIb72TGBTYdf51t5Sga4w2t4iYKvbNsFKW6o/pVAqKt3bBWvHom5As Dl8f5QtyLc3bJ4w6Kqqtt6yWpjXd2XxOi7OD3ksgzCIDImhPUXpXs/49vbg+IaLYEg 6wpFEsgyshaAaIYnrIIBxE2eVcZbbyc6A7bNvsKQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 8AFAD384D19A for ; Wed, 29 Jun 2022 16:37:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8AFAD384D19A Received: by mail-pg1-x533.google.com with SMTP id h192so15849217pgc.4 for ; Wed, 29 Jun 2022 09:37:45 -0700 (PDT) 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=+Aj013EWhfMErMN1FzT2VIR18U2qUc9v2+ZrMaB0BZ0=; b=eqMsaTIQgOmnTsWKVlxR+WQMEXFlAwwzXO7VgyL6kxHTwKPOQL+4NFuFYZOXXqLo9n wy241UwkSSjWJrD3kswKDoIHZsf5a0XyFSLXpk23tAQaz4Wo9/rvr8HKK0LfSf8B0aF5 KdGBF77O7DuDpRHyfo3VluTeed9EIP1yeMnv2bKdh7yo3SV5NEj752gIn1VUOoyvqM1F OqPuec54/8picxARcnBzBVh5irKKLfuyUHba6ZJMx10qKwNtop2kxDwS2NkOdavpRaG9 WVBV4Uoflt/cFUsjYcT9WK+ePtZdwkMTdBD27P349N4VzcuqRTQX1gGh0u8LosoizXYX 0eqg== X-Gm-Message-State: AJIora/4nzs9gwniY7jO2H+VCP4XJtVDVMN51otR4Jj1o478F/HcGV5s L23+S43lm7IC1YR+QbjnMfJ6YdzchGU= X-Google-Smtp-Source: AGRyM1uHdMganhBjud64Y2qfj2oSkafhZG1rpIxpJmZXe1A9my4kzAMyDvAf6MFW7B6MlfT/woVlSQ== X-Received: by 2002:a05:6a00:4194:b0:527:f9a4:73b7 with SMTP id ca20-20020a056a00419400b00527f9a473b7mr2747681pfb.61.1656520664290; Wed, 29 Jun 2022 09:37:44 -0700 (PDT) Received: from ?IPV6:2620:10d:c085:21d6::1133? ([2620:10d:c090:400::5:cb98]) by smtp.googlemail.com with ESMTPSA id bk21-20020aa78315000000b005254e44b748sm11619516pfb.84.2022.06.29.09.37.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jun 2022 09:37:43 -0700 (PDT) Message-ID: <53faea90-bcdb-0a44-6f7b-edfb11efd55f@acm.org> Date: Wed, 29 Jun 2022 12:37:40 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US To: GCC Patches Subject: c++: Rename macro location structs X-Spam-Status: No, score=-3038.9 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Nathan Sidwell via Gcc-patches From: Nathan Sidwell Reply-To: Nathan Sidwell Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The macro location tables should really mention they are about locations. So rename them. Also, add a missing free of the remapping table, and remove some now-unneeded macro checking. nathan From b0f25e1fdc6199725e69023a3dc49021f311ba66 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 24 Jun 2022 05:17:24 -0700 Subject: [PATCH] c++: Rename macro location structs The macro location tables should really mention they are about locations. So rename them. Also, add a missing free of the remapping table, and remove some now-unneeded macro checking. gcc/cp/ * module.cc (macro_info, macro_traits, macro_table, macro_remap): Rename to ... (macro_loc_info, macro_loc_traits, macro_loc_table, macro_loc_remap): ... these. Update all uses. (module_state::write_prepare_maps): Remove unneeded macro checking. (module_state::write_begin): Free macro_loc_remap. --- gcc/cp/module.cc | 73 +++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 48 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 8bb22c2b305..68a7ce53ee4 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -3241,15 +3241,15 @@ public: static loc_spans spans; /* Information about macro locations we stream out. */ -struct macro_info +struct macro_loc_info { const line_map_macro *src; // original expansion unsigned remap; // serialization static int compare (const void *a_, const void *b_) { - auto *a = static_cast (a_); - auto *b = static_cast (b_); + auto *a = static_cast (a_); + auto *b = static_cast (b_); gcc_checking_assert (MAP_START_LOCATION (a->src) != MAP_START_LOCATION (b->src)); @@ -3259,9 +3259,9 @@ struct macro_info return +1; } }; -struct macro_traits +struct macro_loc_traits { - typedef macro_info value_type; + typedef macro_loc_info value_type; typedef const line_map_macro *compare_type; static const bool empty_zero_p = false; @@ -3294,9 +3294,9 @@ struct macro_traits static void remove (value_type &) {} }; /* Table keyed by line_map_macro, used for noting. */ -static hash_table *macro_table; +static hash_table *macro_loc_table; /* Sorted vector, used for writing. */ -static vec *macro_remap; +static vec *macro_loc_remap; /* Indirection to allow bsearching imports by ordinary location. */ static vec *ool; @@ -15616,7 +15616,7 @@ module_state::imported_from () const void module_state::note_location (location_t loc) { - if (!macro_table) + if (!macro_loc_table) ; else if (loc < RESERVED_LOCATION_COUNT) ; @@ -15635,9 +15635,9 @@ module_state::note_location (location_t loc) { const line_map *map = linemap_lookup (line_table, loc); const line_map_macro *mac_map = linemap_check_macro (map); - hashval_t hv = macro_traits::hash (mac_map); - macro_info *slot - = macro_table->find_slot_with_hash (mac_map, hv, INSERT); + hashval_t hv = macro_loc_traits::hash (mac_map); + macro_loc_info *slot + = macro_loc_table->find_slot_with_hash (mac_map, hv, INSERT); if (!slot->src) { slot->src = mac_map; @@ -15698,11 +15698,11 @@ module_state::write_location (bytes_out &sec, location_t loc) } else if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (line_table)) { - const macro_info *info = nullptr; + const macro_loc_info *info = nullptr; unsigned offset = 0; - if (unsigned hwm = macro_remap->length ()) + if (unsigned hwm = macro_loc_remap->length ()) { - info = macro_remap->begin (); + info = macro_loc_remap->begin (); while (hwm != 1) { unsigned mid = hwm / 2; @@ -15909,7 +15909,7 @@ module_state::read_location (bytes_in &sec) const void module_state::write_init_maps () { - macro_table = new hash_table (EXPERIMENT (1, 400)); + macro_loc_table = new hash_table (EXPERIMENT (1, 400)); } location_map_info @@ -15955,30 +15955,6 @@ module_state::write_prepare_maps (module_state_config *cfg) info.num_maps.first += omap - fmap; } - - if (span.macro.first != span.macro.second) - { - /* Iterate over the span's macros, to elide the empty - expansions. */ - unsigned count = 0; - for (unsigned macro - = linemap_lookup_macro_index (line_table, - span.macro.second - 1); - macro < LINEMAPS_MACRO_USED (line_table); - macro++) - { - line_map_macro const *mmap - = LINEMAPS_MACRO_MAP_AT (line_table, macro); - if (MAP_START_LOCATION (mmap) < span.macro.first) - /* Fallen out of the span. */ - break; - - if (mmap->n_tokens) - count++; - } - dump (dumper::LOCATION) && dump ("Span:%u %u macro maps", ix, count); - info.num_maps.second += count; - } } /* Adjust the maps. Ordinary ones ascend, and we must maintain @@ -16024,23 +16000,23 @@ module_state::write_prepare_maps (module_state_config *cfg) ord_off = span.ordinary.second + span.ordinary_delta; } - vec_alloc (macro_remap, macro_table->size ()); - for (auto iter = macro_table->begin (), end = macro_table->end (); + vec_alloc (macro_loc_remap, macro_loc_table->size ()); + for (auto iter = macro_loc_table->begin (), end = macro_loc_table->end (); iter != end; ++iter) - macro_remap->quick_push (*iter); - delete macro_table; - macro_table = nullptr; + macro_loc_remap->quick_push (*iter); + delete macro_loc_table; + macro_loc_table = nullptr; - macro_remap->qsort (¯o_info::compare); + macro_loc_remap->qsort (¯o_loc_info::compare); unsigned offset = 0; - for (auto iter = macro_remap->begin (), end = macro_remap->end (); + for (auto iter = macro_loc_remap->begin (), end = macro_loc_remap->end (); iter != end; ++iter) { auto mac = iter->src; iter->remap = offset; offset += mac->n_tokens; } - info.num_maps.second = macro_remap->length (); + info.num_maps.second = macro_loc_remap->length (); cfg->macro_locs = offset; dump () && dump ("Ordinary:%u maps hwm:%u macro:%u maps %u locs", @@ -16244,7 +16220,7 @@ module_state::write_macro_maps (elf_out *to, location_map_info &info, sec.u (info.num_maps.second); unsigned macro_num = 0; - for (auto iter = macro_remap->end (), begin = macro_remap->begin (); + for (auto iter = macro_loc_remap->end (), begin = macro_loc_remap->begin (); iter-- != begin;) { auto mac = iter->src; @@ -17936,6 +17912,7 @@ module_state::write_begin (elf_out *to, cpp_reader *reader, spaces.release (); sccs.release (); + vec_free (macro_loc_remap); vec_free (ool); // FIXME:QOI: Have a command line switch to control more detailed -- 2.30.2