From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72330 invoked by alias); 13 Apr 2016 19:18:40 -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 72166 invoked by uid 89); 13 Apr 2016 19:18:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mx2.suse.de Received: from mx2.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, 13 Apr 2016 19:18:38 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 79B81ABB0; Wed, 13 Apr 2016 19:18:34 +0000 (UTC) User-Agent: K-9 Mail for Android In-Reply-To: <20160413143225.GO19207@tucnak.redhat.com> References: <20160412145427.GV19207@tucnak.redhat.com> <06F4B65D-FBCA-4653-B7A7-D47FF748F251@suse.de> <20160412155516.GZ19207@tucnak.redhat.com> <140A6BFE-E821-4CDF-B463-8489EDA2A2A6@suse.de> <20160412184757.GB19207@tucnak.redhat.com> <20160413143225.GO19207@tucnak.redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] Don't include DECL_UIDs in tree-sra fancy names for -fdump-final-insns= (PR c++/70594) From: Richard Biener Date: Wed, 13 Apr 2016 19:18:00 -0000 To: Jakub Jelinek CC: Martin Jambor ,Jason Merrill ,gcc-patches@gcc.gnu.org Message-ID: <9DF033D5-66E5-47DD-A1EC-4E0C92EA5BBD@suse.de> X-SW-Source: 2016-04/txt/msg00629.txt.bz2 On April 13, 2016 4:32:25 PM GMT+02:00, Jakub Jelinek wrote: >On Wed, Apr 13, 2016 at 09:25:56AM +0200, Richard Biener wrote: >> So if you think it's not acceptable to drop the relation between >> the artificial number used by SRA and the original UID then go >> with a hash-map unconditionally. You still have to dump and lookup >> the actual relation though - there's no way around this unless you >> hack dump-final-insns to filter DECL names (maybe just make it >> strip all DECL_ARTIFICIAL names completely?) > >Here is an alternative patch, keep the fancy names as before, >but in TDF_NOUID dumps sanitize them. Most of the DECL_NAMELESS >decls other than ones with the SRA fancy names should not contain >anything that would be tweaked for the printout, and doing it this >way has the advantage that one can always just use flags without >TDF_NOUID >to see the real fancy names. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Richard. >2016-04-13 Jakub Jelinek > > PR c++/70594 > * tree-sra.c (create_access_replacement, > get_replaced_param_substitute): Set DECL_NAMELESS on repl if it > gets fancy name. > * tree-pretty-print.c (dump_fancy_name): New function. > (dump_decl_name, dump_generic_node): Use it. > >--- gcc/tree-sra.c.jj 2016-04-12 19:12:34.000000000 +0200 >+++ gcc/tree-sra.c 2016-04-13 13:52:28.329925560 +0200 >@@ -2132,6 +2132,7 @@ create_access_replacement (struct access > bool fail = false; > > DECL_NAME (repl) = get_identifier (pretty_name); >+ DECL_NAMELESS (repl) = 1; > obstack_free (&name_obstack, pretty_name); > > /* Get rid of any SSA_NAMEs embedded in debug_expr, >@@ -4704,6 +4705,7 @@ get_replaced_param_substitute (struct ip > > repl = create_tmp_reg (TREE_TYPE (adj->base), "ISR"); > DECL_NAME (repl) = get_identifier (pretty_name); >+ DECL_NAMELESS (repl) = 1; > obstack_free (&name_obstack, pretty_name); > > adj->new_ssa_base = repl; >--- gcc/tree-pretty-print.c.jj 2016-03-17 16:54:44.000000000 +0100 >+++ gcc/tree-pretty-print.c 2016-04-13 14:10:59.667085487 +0200 >@@ -161,6 +161,85 @@ print_generic_expr (FILE *file, tree t, > pp_flush (tree_pp); > } > >+/* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D >sequences >+ in it are replaced with Dxxxx, as long as they are at the start or >+ preceded by $ and at the end or followed by $. See make_fancy_name >+ in tree-sra.c. */ >+ >+static void >+dump_fancy_name (pretty_printer *pp, tree name) >+{ >+ int cnt = 0; >+ int length = IDENTIFIER_LENGTH (name); >+ const char *n = IDENTIFIER_POINTER (name); >+ do >+ { >+ n = strchr (n, 'D'); >+ if (n == NULL) >+ break; >+ if (ISDIGIT (n[1]) >+ && (n == IDENTIFIER_POINTER (name) || n[-1] == '$')) >+ { >+ int l = 2; >+ while (ISDIGIT (n[l])) >+ l++; >+ if (n[l] == '\0' || n[l] == '$') >+ { >+ cnt++; >+ length += 5 - l; >+ } >+ n += l; >+ } >+ else >+ n++; >+ } >+ while (1); >+ if (cnt == 0) >+ { >+ pp_tree_identifier (pp, name); >+ return; >+ } >+ >+ char *str = XNEWVEC (char, length + 1); >+ char *p = str; >+ const char *q; >+ q = n = IDENTIFIER_POINTER (name); >+ do >+ { >+ q = strchr (q, 'D'); >+ if (q == NULL) >+ break; >+ if (ISDIGIT (q[1]) >+ && (q == IDENTIFIER_POINTER (name) || q[-1] == '$')) >+ { >+ int l = 2; >+ while (ISDIGIT (q[l])) >+ l++; >+ if (q[l] == '\0' || q[l] == '$') >+ { >+ memcpy (p, n, q - n); >+ memcpy (p + (q - n), "Dxxxx", 5); >+ p += (q - n) + 5; >+ n = q + l; >+ } >+ q += l; >+ } >+ else >+ q++; >+ } >+ while (1); >+ memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER >(name))); >+ str[length] = '\0'; >+ if (pp_translate_identifiers (pp)) >+ { >+ const char *text = identifier_to_locale (str); >+ pp_append_text (pp, text, text + strlen (text)); >+ } >+ else >+ pp_append_text (pp, str, str + length); >+ XDELETEVEC (str); >+} >+ > /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set > in FLAGS. */ > >@@ -171,6 +250,10 @@ dump_decl_name (pretty_printer *pp, tree > { > if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node)) > pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node)); >+ /* For DECL_NAMELESS names look for embedded uids in the >+ names and sanitize them for TDF_NOUID. */ >+ else if ((flags & TDF_NOUID) && DECL_NAMELESS (node)) >+ dump_fancy_name (pp, DECL_NAME (node)); > else > pp_tree_identifier (pp, DECL_NAME (node)); > } >@@ -2593,8 +2676,15 @@ dump_generic_node (pretty_printer *pp, t > > case SSA_NAME: > if (SSA_NAME_IDENTIFIER (node)) >- dump_generic_node (pp, SSA_NAME_IDENTIFIER (node), >- spc, flags, false); >+ { >+ if ((flags & TDF_NOUID) >+ && SSA_NAME_VAR (node) >+ && DECL_NAMELESS (SSA_NAME_VAR (node))) >+ dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node)); >+ else >+ dump_generic_node (pp, SSA_NAME_IDENTIFIER (node), >+ spc, flags, false); >+ } > pp_underscore (pp); > pp_decimal_int (pp, SSA_NAME_VERSION (node)); > if (SSA_NAME_IS_DEFAULT_DEF (node)) > > > Jakub