From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52908 invoked by alias); 26 Oct 2017 12:46:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52895 invoked by uid 89); 26 Oct 2017 12:46:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f177.google.com Received: from mail-yw0-f177.google.com (HELO mail-yw0-f177.google.com) (209.85.161.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Oct 2017 12:46:25 +0000 Received: by mail-yw0-f177.google.com with SMTP id j4so2782726ywb.2 for ; Thu, 26 Oct 2017 05:46:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=MT06Qy8/+lqd4bBLvKh5GGmx9/ouEMG3uO2UAz/bsvk=; b=J/ehMLB1krmDTKK9f2cf6eRuZUb5Y2FOQZd7x9iWjIKhUlnf8urH7+v18S1NZVDPjq 6bluSmeY8DJrpsaWxO2/0CGqaNVsZWzLqLIhRqX/p3sscXKq3oJgC8Rkr0PJWe9wcScj KFWxXZstd81olD/Bsl1xiBaBcwhdWYBvn3fhAj5hoxk5CjSZKYJM4WbIBeHcqUnHtqiD 27X5mqSwFNcfF48UMPjPkCjGpCeNxtATF/yGJFsbLwUx3xuEVWUKOVlD+80hm/I42XbZ YQB83fQa8thzVIuYYg9uXL8bNxqEePrL2Y2AFn09lDK3ofW/INWCdWh9aNl5oGFnqarf IaFw== X-Gm-Message-State: AMCzsaVXqvrieCJ3CYgs35YysNejrXXFirMbTVkCEhb6J1Nc9yD1tgx+ DPw3YuRSXFIMcLorCvS/wqs= X-Google-Smtp-Source: ABhQp+TKH3IbZrxpRpVe5uFot3cuLPXyLbsC/qYT8/uNXQBz1MJmOzBaCCd0oZywU/kXStmZ9ajxQA== X-Received: by 10.129.92.198 with SMTP id q189mr15886754ywb.417.1509021983167; Thu, 26 Oct 2017 05:46:23 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3b0e]) by smtp.googlemail.com with ESMTPSA id x126sm2243371ywf.109.2017.10.26.05.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 05:46:21 -0700 (PDT) Subject: Re: [C++ PATCH] Kill IDENTIFIER_LABEL_VALUE From: Nathan Sidwell To: GCC Patches References: <8d7a547f-3d8e-7a99-5298-e8625863602e@acm.org> Message-ID: <6d8fac60-9978-47b5-7be9-b98c7d9f46e7@acm.org> Date: Thu, 26 Oct 2017 12:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <8d7a547f-3d8e-7a99-5298-e8625863602e@acm.org> Content-Type: multipart/mixed; boundary="------------D1A12A84BEFD8147228640C7" X-SW-Source: 2017-10/txt/msg01936.txt.bz2 This is a multi-part message in MIME format. --------------D1A12A84BEFD8147228640C7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1110 On 10/25/2017 05:36 PM, Nathan Sidwell wrote: > This patch removes 'label_value' from lang_identifier, shrinking it from > 72 to 64 bytes (on 64-bit machine).   We replace this by augmenting the > already used per-function named_labels hash table.  This is a major win, > because labels are extremely rare and there are many identifiers.  We > also shring the binding structure by a pointer, as the shadowed_labels > list goes away. I was a little over zealous killing code, but perhaps now this is being a little paranoid. It restore the UID sorting of labels when inserting them into the BLOCK chain. The original comment was confusing, as it mentioned code generation and then debug information. I think this just affects the order of debug records, but ICBW. For any given function, the iteration of the hash table should be stable across versions, unless the hash table implementation or the IDENTIFIER_HASH_VALUE changes. But may as well be safe. I also add the N_ translation markup I forgot about yesterday when taking strings out of 'inform' calls. nathan -- Nathan Sidwell --------------D1A12A84BEFD8147228640C7 Content-Type: text/x-patch; name="label-2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="label-2.diff" Content-length: 3563 2017-10-26 Nathan Sidwell * decl.c (sort_labels): Restore function. (pop_labels): Sort labels (identify_goto): Add translation markup. Index: decl.c =================================================================== --- decl.c (revision 254087) +++ decl.c (working copy) @@ -372,6 +372,18 @@ check_label_used (tree label) } } +/* Helper function to sort named label entries in a vector by DECL_UID. */ + +static int +sort_labels (const void *a, const void *b) +{ + tree label1 = *(tree const *) a; + tree label2 = *(tree const *) b; + + /* DECL_UIDs can never be equal. */ + return DECL_UID (label1) > DECL_UID (label2) ? -1 : +1; +} + /* At the end of a function, all labels declared within the function go out of scope. BLOCK is the top-level block for the function. */ @@ -382,6 +394,12 @@ pop_labels (tree block) if (!named_labels) return; + /* We need to add the labels to the block chain, so debug + information is emitted. But, we want the order to be stable so + need to sort them first. Otherwise the debug output could be + randomly ordered. I guess it's mostly stable, unless the hash + table implementation changes. */ + auto_vec labels (named_labels->elements ()); hash_table::iterator end (named_labels->end ()); for (hash_table::iterator iter (named_labels->begin ()); iter != end; ++iter) @@ -390,18 +408,21 @@ pop_labels (tree block) gcc_checking_assert (!ent->outer); if (ent->label_decl) - { - check_label_used (ent->label_decl); - - /* Put the labels into the "variables" of the top-level block, - so debugger can see them. */ - DECL_CHAIN (ent->label_decl) = BLOCK_VARS (block); - BLOCK_VARS (block) = ent->label_decl; - } + labels.quick_push (ent->label_decl); ggc_free (ent); } - named_labels = NULL; + labels.qsort (sort_labels); + + while (labels.length ()) + { + tree label = labels.pop (); + + DECL_CHAIN (label) = BLOCK_VARS (block); + BLOCK_VARS (block) = label; + + check_label_used (label); + } } /* At the end of a block with local labels, restore the outer definition. */ @@ -3066,8 +3087,8 @@ identify_goto (tree decl, location_t loc { bool complained = emit_diagnostic (diag_kind, loc, 0, - decl ? "jump to label %qD" : "jump to case label", - decl); + decl ? N_("jump to label %qD") + : N_("jump to case label"), decl); if (complained && locus) inform (*locus, " from here"); return complained; @@ -3136,32 +3157,32 @@ check_previous_goto_1 (tree decl, cp_bin { case sk_try: if (!saw_eh) - inf = "enters try block"; + inf = N_("enters try block"); saw_eh = true; break; case sk_catch: if (!saw_eh) - inf = "enters catch block"; + inf = N_("enters catch block"); saw_eh = true; break; case sk_omp: if (!saw_omp) - inf = "enters OpenMP structured block"; + inf = N_("enters OpenMP structured block"); saw_omp = true; break; case sk_transaction: if (!saw_tm) - inf = "enters synchronized or atomic statement"; + inf = N_("enters synchronized or atomic statement"); saw_tm = true; break; case sk_block: if (!saw_cxif && level_for_constexpr_if (b->level_chain)) { - inf = "enters constexpr if statement"; + inf = N_("enters constexpr if statement"); loc = EXPR_LOCATION (b->level_chain->this_entity); saw_cxif = true; } --------------D1A12A84BEFD8147228640C7--