From patchwork Thu Feb 17 12:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 51181 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 6E29E3857029 for ; Thu, 17 Feb 2022 12:23:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 796813858014 for ; Thu, 17 Feb 2022 12:23:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 796813858014 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: 5MKjpUbqU6al74um0li2fRK0IED7BegiLcMqByXZOJg28QXfFzPR3NUo9TgN2P4BqJavRjzBoM 17ZB4Ep0PSpj6mq4JiANL49j5+B5Ty8Ekq1qDLI0uFVOXAOF+MKlD0OSsF7qEM0vizosD0zM2D NEvJYRq0uLDTwWzIdMPRTaqJzFuBx6S9KLSM1oGUenBEZI6dfMrIJLuvGDTypn4Uz5Q6MruvBP C5fo8/WvaR2yBuE08cLqeTxDEYzqRNn0yPbHZP7uAbkz/W9YtezIu1E+hHe1xdwB3Vy/hGM35C xBstQm5H+mh+G6D2kNuDG1tu X-IronPort-AV: E=Sophos;i="5.88,375,1635235200"; d="scan'208,223";a="72074742" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 17 Feb 2022 04:23:12 -0800 IronPort-SDR: LU0XImXQQ710KeSmKT2iGbceWR+BQTcc28CXJrtAKgAXRTCbwXijDcx0+9tAbKu+Aav6s8kpML qYJymzYSM0mHO+0jXcOysUumm6KJ7SB+NW9dNamgIaQJPeJVn0lC+GsC6btyqNMa6Hschp59zM 8WY4kEUnsChmq9W4wHNWL4IcR6BOkQhvA+U+MqhiKU3Xtti3GcgZToCfsNCfVK7I6kSJhs9GjH i/8KOGXMCD0DA4y9KuPq+OhO+ObGQEEnaShQDxXVAaHHC3RSLy2Ll9OFdB4FwgVBN9M4BURCMr lQA= From: Thomas Schwinge To: Richard Biener , Subject: Consider 'TDF_UID', 'TDF_NOUID' in 'print_node_brief', 'print_node' In-Reply-To: References: <87fsosmb17.fsf@dem-tschwing-1.ger.mentorg.com> <87r18auzxy.fsf@dirichlet.schwinge.homeip.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Thu, 17 Feb 2022 13:23:01 +0100 Message-ID: <878ru9ptqy.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Cc: Michael Matz Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2022-02-11T08:02:20+0100, Richard Biener wrote: > On Thu, Feb 10, 2022 at 11:20 PM Thomas Schwinge > wrote: >> On 2022-02-10T16:36:51+0000, Michael Matz via Gcc-patches wrote: >> > On Thu, 10 Feb 2022, Richard Biener via Gcc-patches wrote: >> >> On Wed, Feb 9, 2022 at 2:21 PM Thomas Schwinge wrote: >> >> > OK to push (now, or in next development stage 1?) the attached >> >> > "Consider 'TDF_UID', 'TDF_NOUID' in 'print_node_brief', 'print_node'", >> >> > or should that be done differently -- or, per the current state (why?) >> >> > not at all? >> >> First, thanks for (indirectly) having confirmed that my confusion is not >> completely off, why this is currently missing. ;-) >> >> >> Hmm, I wonder if we shouldn't simply dump DECL_UID as >> >> >> >> 'uid NNN' >> > >> > Yes, much better in line with the normal dump_tree output. >> >> >> somewhere. For example after or before DECL_NAME? >> >> Heh -- that's what I wanted to do initially, but then I saw that we've >> currently got in 'print_node_brief' (and very similar in 'print_node'): >> >> [...] >> fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node))); >> dump_addr (file, " ", node); >> >> if (tclass == tcc_declaration) >> { >> if (DECL_NAME (node)) >> fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); >> else if (TREE_CODE (node) == LABEL_DECL >> && LABEL_DECL_UID (node) != -1) >> { >> if (dump_flags & TDF_NOUID) >> fprintf (file, " L.xxxx"); >> else >> fprintf (file, " L.%d", (int) LABEL_DECL_UID (node)); >> } >> else >> { >> if (dump_flags & TDF_NOUID) >> fprintf (file, " %c.xxxx", >> TREE_CODE (node) == CONST_DECL ? 'C' : 'D'); >> else >> fprintf (file, " %c.%u", >> TREE_CODE (node) == CONST_DECL ? 'C' : 'D', >> DECL_UID (node)); >> } >> } >> [...] >> >> That is, if there's no 'DECL_NAME', we print 'L.[UID]', 'C.[UID]', >> 'D.[UID]'. The same we do in 'gcc/tree-pretty-print.cc:dump_decl_name', >> I found. But in the latter function, we also do it that same way if >> there is a 'DECL_NAME' ('i' -> 'iD.4249', for example), so that's why I >> copied that style back to my proposed 'print_node_brief'/'print_node' >> change. >> >> Are you now suggesting to only print 'DECL_NAME' as '[NAME] uid [UID]', >> but keep 'L.[UID]', 'C.[UID]', 'D.[UID]' in the "dot" form, or change >> these to 'L uid [UID]', 'C uid [UID]', 'D uid [UID]' correspondingly? > > I'd say these should then be 'D.[UID] uid [UID]' even if that's > somewhat redundant. Sure, that's fine for me. So, like in the attached "Consider 'TDF_UID', 'TDF_NOUID' in 'print_node_brief', 'print_node'"; OK to push? (... which evidently I forgot to send last week...) Grüße Thomas >> And also do the similar changes in >> 'gcc/tree-pretty-print.cc:dump_decl_name' (as well as another dozen or so >> places where such things are printed...), or don't change those? > > Don't change those - you were targeting the tree dumper, not the > pretty printers. > The tree dumpers generally dump attributes separately. > > >> >> I don't care very much which way, just have some slight preference to >> keep things similar. >> >> >> Grüße >> Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 0a39ef2415e5b43755556e5554533b33ff86f16d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 11 Feb 2022 10:10:25 +0100 Subject: [PATCH] Consider 'TDF_UID', 'TDF_NOUID' in 'print_node_brief', 'print_node' Running GCC with '-fdump-tree-all-uid' (so that 'TDF_UID' is set in 'dump_flags') and '-wrapper gdb,--args', then for a 'call debug_tree(decl)', that does (pretty-)print all kinds of things -- but not the 'DECL_UID': [...] (gdb) print dump_flags & TDF_UID $1 = 256 (gdb) call debug_tree(decl) unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff75555e8 precision:32 min max pointer_to_this > used SI source-gcc/gcc/testsuite/gfortran.dg/goacc-gomp/pr102330-3.f90:10:3 size unit-size align:32 warn_if_not_align:0 context > (gdb) print decl.decl_minimal.uid $3 = 4249 In my opinion, that's a bit unfortunate, as the 'DECL_UID' is very important for debugging certain classes of issues. With this patch, there is no change if 'TDF_UID' isn't set, but if it is, we now append 'uid [DECL_UID]': unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff75555e8 precision:32 min max pointer_to_this > used SI source-gcc/gcc/testsuite/gfortran.dg/goacc-gomp/pr102330-3.f90:6:3 size unit-size align:32 warn_if_not_align:0 context > Notice 'var_decl': 'i uid 4249', and 'function_decl': 'p uid 4227'. A few 'print_node_brief' examples: '!TDF_UID', '!TDF_NOUID' (no change): '!TDF_UID', 'TDF_NOUID' (no change): 'TDF_UID', '!TDF_NOUID' (now appends 'uid [DECL_UID]'): 'TDF_UID', 'TDF_NOUID' (now appends 'uid xxxx'): gcc/ * print-tree.cc (print_node_brief, print_node): Consider 'TDF_UID', 'TDF_NOUID'. --- gcc/print-tree.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc index 0876da873a9..38dd032fbf7 100644 --- a/gcc/print-tree.cc +++ b/gcc/print-tree.cc @@ -158,6 +158,14 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent) TREE_CODE (node) == CONST_DECL ? 'C' : 'D', DECL_UID (node)); } + + if (dump_flags & TDF_UID) + { + if (dump_flags & TDF_NOUID) + fprintf (file, " uid xxxx"); + else + fprintf (file, " uid %d", DECL_UID (node)); + } } else if (tclass == tcc_type) { @@ -301,6 +309,14 @@ print_node (FILE *file, const char *prefix, tree node, int indent, fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D', DECL_UID (node)); } + + if (dump_flags & TDF_UID) + { + if (dump_flags & TDF_NOUID) + fprintf (file, " uid xxxx"); + else + fprintf (file, " uid %d", DECL_UID (node)); + } } else if (tclass == tcc_type) { -- 2.34.1