From patchwork Tue Oct 5 10:35:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 45828 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F8C6385AC0A for ; Tue, 5 Oct 2021 10:36:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F8C6385AC0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633430163; bh=Q7+VyC5QqBmXHBRHCA/69GYl/s/PAvbEre87umUQ8u4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=K3eltSvN5st8XUfBuGDIZhS3pB/s06/oLSh5pH+O94CLSVmOZh6Qa17oIlQL+gsHH GM9Kex/t4E7rErmBsFfNaZjj8g7lFnAqsC3e+rlHgOQzYJQv/mT3Hh5pJS6lxm/1LP rUvsiXomrPxm3/OnY11Jf39FcON0YcqOqHi21kFg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 767BB385840B for ; Tue, 5 Oct 2021 10:35:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 767BB385840B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 52C1F20002 for ; Tue, 5 Oct 2021 10:35:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 40BA113C2B for ; Tue, 5 Oct 2021 10:35:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6grJDnUqXGFtIwAAMHmgww (envelope-from ) for ; Tue, 05 Oct 2021 10:35:33 +0000 Date: Tue, 5 Oct 2021 12:35:32 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Amend function names with UID when dumping with TDF_UID Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 * 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(-) 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); }