[PATCH] Don't include DECL_UIDs in tree-sra fancy names for -fdump-final-insns= (PR c++/70594)
Richard Biener
rguenther@suse.de
Wed Apr 13 19:18:00 GMT 2016
On April 13, 2016 4:32:25 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> 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 <jakub@redhat.com>
>
> 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<num>
>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
More information about the Gcc-patches
mailing list