From patchwork Wed Mar 18 13:59:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 451467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E7D12140082 for ; Thu, 19 Mar 2015 00:59:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=SxjI9e3g; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=OYm9gboK73eiVebqM ltiOWydhl25p+xp/4AzK8IuE7zWDYKTMSbm81KAF16+KA6BhwH7LTHHwZaJJyS9Z 17vpEl7bv0Y3MHWK95BXUgY7Xjcjhcf7SfSramWc75ge6oTCWfHhzJwGsWTrb5VH iddrihqzXdNsvCI83BgRFMV23k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=ogzPh1lk7V2enlqaccpk5Sf kjvA=; b=SxjI9e3gpDJv/Tr+Iwz9kQgjZrMLNKObCXqsdhniLQt1eW5jdO9xFb8 GmRdK4vzcGf4t7Hrh+XtycbknlqWyEZkX5sAgbViqBMjha2K4ill5Gk8ku28bnqV xbdKEeuJy9rih/89uUWwUdvM4MFrOo5NGK87Iit3Dm1CVKqyWCkk= Received: (qmail 41090 invoked by alias); 18 Mar 2015 13:59:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 41023 invoked by uid 89); 18 Mar 2015 13:59:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 18 Mar 2015 13:59:14 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 94698AC15 for ; Wed, 18 Mar 2015 13:59:11 +0000 (UTC) Message-ID: <550984AE.9080903@suse.cz> Date: Wed, 18 Mar 2015 14:59:10 +0100 From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR ipa/65432 References: <55097C8A.80002@suse.cz> In-Reply-To: X-IsSubscribed: yes TOn 03/18/2015 02:33 PM, Richard Biener wrote: > On Wed, Mar 18, 2015 at 2:24 PM, Martin Liška wrote: >> Hello. >> >> Following patch wraps symtab_node::{asm_}name with xstrdup_for_dump. >> >> Ready for trunk? > > /* Gets symbol name of the item. */ > const char *name (void) > { > - return node->name (); > + return xstrdup_for_dump (node->name ()); > > shouldn't the methods be called dump_name () then? And why's > node->name () not already dup-ing the string? > > That said, I wonder where we use ->name / ->asm_name. And why > that's different for ICF. > > The patch would be more obvious if all fixes were to dumping sites. > > Richard. Hi. I decided to remove sem_item::{asm_}name as it really just calls symtab_node::{asm_}name. And the patch uses xstrdup_for_dump just dumping sites with more than one {asm_}name calls. Martin > >> Thanks, >> Martin From 5d2e883524ba23155d80cd4ad6d58ba5c73a1f90 Mon Sep 17 00:00:00 2001 From: mliska Date: Wed, 18 Mar 2015 13:59:49 +0100 Subject: [PATCH] Fix PR ipa/65432 gcc/ChangeLog: 2015-03-18 Martin Liska * cgraph.c (cgraph_node::get_create): Remove unnecessary xstrdup_for_dump wrapper. * ipa-icf.c (sem_item::dump): Use symtab_node::name instead of sem_item::name. (sem_function::equals): Wrap symtab_node::name and symtab_node::asm_name with xstrdup_for_dump. (sem_variable::equals): Likewise. (sem_item_optimizer::read_section): Use symtab_node::name instead of sem_item::name. (sem_item_optimizer::parse_funcs_and_vars): Likewise. (sem_item_optimizer::merge_classes): Wrap symtab_node::name and symtab_node::asm_name with xstrdup_for_dump. (congruence_class::dump): Use symtab_node::name instead of sem_item::name. * ipa-icf.h (symtab_node::name): Remove. (symtab_node::asm_name): Likewise. --- gcc/cgraph.c | 5 ++--- gcc/ipa-icf.c | 35 +++++++++++++++++++++++------------ gcc/ipa-icf.h | 12 ------------ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index ede58bf..e2958c4 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -553,12 +553,11 @@ cgraph_node::get_create (tree decl) if (dump_file) fprintf (dump_file, "Introduced new external node " "(%s/%i) and turned into root of the clone tree.\n", - xstrdup_for_dump (node->name ()), node->order); + node->name (), node->order); } else if (dump_file) fprintf (dump_file, "Introduced new external node " - "(%s/%i).\n", xstrdup_for_dump (node->name ()), - node->order); + "(%s/%i).\n", node->name (), node->order); return node; } diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 25b8306..f68d23c 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -239,12 +239,12 @@ sem_item::dump (void) if (dump_file) { fprintf (dump_file, "[%s] %s (%u) (tree:%p)\n", type == FUNC ? "func" : "var", - name(), node->order, (void *) node->decl); + node->name(), node->order, (void *) node->decl); fprintf (dump_file, " hash: %u\n", get_hash ()); fprintf (dump_file, " references: "); for (unsigned i = 0; i < refs.length (); i++) - fprintf (dump_file, "%s%s ", refs[i]->name (), + fprintf (dump_file, "%s%s ", refs[i]->node->name (), i < refs.length() - 1 ? "," : ""); fprintf (dump_file, "\n"); @@ -575,8 +575,13 @@ sem_function::equals (sem_item *item, if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Equals called for:%s:%s (%u:%u) (%s:%s) with result: %s\n\n", - name(), item->name (), node->order, item->node->order, asm_name (), - item->asm_name (), eq ? "true" : "false"); + xstrdup_for_dump (node->name()), + xstrdup_for_dump (item->node->name ()), + node->order, + item->node->order, + xstrdup_for_dump (node->asm_name ()), + xstrdup_for_dump (item->node->asm_name ()), + eq ? "true" : "false"); return eq; } @@ -1522,8 +1527,11 @@ sem_variable::equals (sem_item *item, if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Equals called for vars:%s:%s (%u:%u) (%s:%s) with result: %s\n\n", - name(), item->name (), node->order, item->node->order, asm_name (), - item->asm_name (), ret ? "true" : "false"); + xstrdup_for_dump (node->name()), + xstrdup_for_dump (item->node->name ()), + node->order, item->node->order, + xstrdup_for_dump (node->asm_name ()), + xstrdup_for_dump (item->node->asm_name ()), ret ? "true" : "false"); return ret; } @@ -1995,8 +2003,8 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, gcc_assert (node->definition); if (dump_file) - fprintf (dump_file, "Symbol added:%s (tree: %p, uid:%u)\n", node->asm_name (), - (void *) node->decl, node->order); + fprintf (dump_file, "Symbol added:%s (tree: %p, uid:%u)\n", + node->asm_name (), (void *) node->decl, node->order); if (is_a (node)) { @@ -2259,7 +2267,7 @@ sem_item_optimizer::parse_funcs_and_vars (void) m_symtab_node_map.put (cnode, f); if (dump_file) - fprintf (dump_file, "Parsed function:%s\n", f->asm_name ()); + fprintf (dump_file, "Parsed function:%s\n", f->node->asm_name ()); if (dump_file && (dump_flags & TDF_DETAILS)) f->dump_to_file (dump_file); @@ -2955,9 +2963,11 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) if (dump_file) { fprintf (dump_file, "Semantic equality hit:%s->%s\n", - source->name (), alias->name ()); + xstrdup_for_dump (source->node->name ()), + xstrdup_for_dump (alias->node->name ())); fprintf (dump_file, "Assembler symbol names:%s->%s\n", - source->asm_name (), alias->asm_name ()); + xstrdup_for_dump (source->node->asm_name ()), + xstrdup_for_dump (alias->node->asm_name ())); } if (lookup_attribute ("no_icf", DECL_ATTRIBUTES (alias->decl))) @@ -2993,7 +3003,8 @@ congruence_class::dump (FILE *file, unsigned int indent) const FPUTS_SPACES (file, indent + 2, ""); for (unsigned i = 0; i < members.length (); i++) - fprintf (file, "%s(%p/%u) ", members[i]->asm_name (), (void *) members[i]->decl, + fprintf (file, "%s(%p/%u) ", members[i]->node->asm_name (), + (void *) members[i]->decl, members[i]->node->order); fprintf (file, "\n"); diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index c51bb4a..8245b54 100644 --- a/gcc/ipa-icf.h +++ b/gcc/ipa-icf.h @@ -171,18 +171,6 @@ public: /* Add reference to a semantic TARGET. */ void add_reference (sem_item *target); - /* Gets symbol name of the item. */ - const char *name (void) - { - return node->name (); - } - - /* Gets assembler name of the item. */ - const char *asm_name (void) - { - return node->asm_name (); - } - /* Fast equality function based on knowledge known in WPA. */ virtual bool equals_wpa (sem_item *item, hash_map &ignored_nodes) = 0; -- 2.1.2