]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Amend function names with UID when dumping with TDF_UID
authorRichard Biener <rguenther@suse.de>
Tue, 5 Oct 2021 09:41:42 +0000 (11:41 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 5 Oct 2021 10:35:40 +0000 (12:35 +0200)
The following makes sure to amend more function names with the
associated DECL_UID when dumping with TDF_UID, in particular
function names printed as part of calls and in the function header.
That allows one to more easily follow the call flow of PR102528
where coroutines cause three clones of the name 'test2' that are
not distinguishable otherwise.

2021-10-05  Richard Biener  <rguenther@suse.de>

* tree-cfg.c (dump_function_to_file): Dump the UID of the
function as part of the name when requested.
* tree-pretty-print.c (dump_function_name): Dump the UID when
requested and the langhook produced the actual name.

gcc/tree-cfg.c
gcc/tree-pretty-print.c

index 367dcfa20bf899034abda55bd01837495235e3cb..4b4b0b52d9a762c93d8a5fa301fce1b8b459b208 100644 (file)
@@ -8127,14 +8127,22 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
            fprintf (file, ",%s(%" PRIu64 ")",
                     profile_quality_as_string (bb->count.quality ()),
                     bb->count.value ());
-         fprintf (file, ")\n%s (", function_name (fun));
+         if (dump_flags & TDF_UID)
+           fprintf (file, ")\n%sD_%u (", function_name (fun),
+                    DECL_UID (fndecl));
+         else
+           fprintf (file, ")\n%s (", function_name (fun));
        }
     }
   else
     {
       print_generic_expr (file, TREE_TYPE (fntype), dump_flags);
-      fprintf (file, " %s %s(", function_name (fun),
-              tmclone ? "[tm-clone] " : "");
+      if (dump_flags & TDF_UID)
+       fprintf (file, " %sD.%u %s(", function_name (fun), DECL_UID (fndecl),
+                tmclone ? "[tm-clone] " : "");
+      else
+       fprintf (file, " %s %s(", function_name (fun),
+                tmclone ? "[tm-clone] " : "");
     }
 
   arg = DECL_ARGUMENTS (fndecl);
index 0b5bdd78f064cd28189f5d2148856562af013c09..81d86ebf97d70ef9c8165b120d2ae3f5b5fba09e 100644 (file)
@@ -344,7 +344,16 @@ dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
   if (CONVERT_EXPR_P (node))
     node = TREE_OPERAND (node, 0);
   if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
-    pp_string (pp, lang_hooks.decl_printable_name (node, 1));
+    {
+      pp_string (pp, lang_hooks.decl_printable_name (node, 1));
+      if (flags & TDF_UID)
+       {
+         char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
+         pp_character (pp, 'D');
+         pp_character (pp, uid_sep);
+         pp_scalar (pp, "%u", DECL_UID (node));
+       }
+    }
   else
     dump_decl_name (pp, node, flags);
 }