Amend function names with UID when dumping with TDF_UID

Message ID o1o42p67-nqo8-rp5p-6895-q85pn8s04975@fhfr.qr
State Committed
Commit eded91050982dc4d7968fecf65469f1ef68854f9
Headers
Series Amend function names with UID when dumping with TDF_UID |

Commit Message

Richard Biener Oct. 5, 2021, 10:35 a.m. UTC
  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.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

Richard.

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          | 14 +++++++++++---
 gcc/tree-pretty-print.c | 11 ++++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 367dcfa20bf..4b4b0b52d9a 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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);
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 0b5bdd78f06..81d86ebf97d 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -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);
 }