From: Richard Biener Date: Tue, 5 Oct 2021 09:41:42 +0000 (+0200) Subject: Amend function names with UID when dumping with TDF_UID X-Git-Tag: basepoints/gcc-13~4130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eded91050982dc4d7968fecf65469f1ef68854f9;p=thirdparty%2Fgcc.git Amend function names with UID when dumping with TDF_UID 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 * 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. --- diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 367dcfa20bf8..4b4b0b52d9a7 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 0b5bdd78f064..81d86ebf97d7 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); }