From patchwork Mon Nov 15 11:18:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1555257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ht6CX2WFfz9s0r for ; Mon, 15 Nov 2021 22:19:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28B25385781F for ; Mon, 15 Nov 2021 11:19:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 2D95D3858D39 for ; Mon, 15 Nov 2021 11:18:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D95D3858D39 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: cKQZHWIIpUmFDg533oHKEvNJU0d5rq2srHxSO+lNEu9Gf93dGNwC4NqVetqQkf3WWzkM0n++7T sKArt4zShAv1mP0Ks2fuyc6ZpsntznhAo32CwgKuDElCHhgNRonweC+4VoLZpwoDcxfCr8Yqml hosVWrTY39udd4LxQE2PIDYfXY0aePexLzSL7r0I2m2cZ7rrN0nYHizzTXBGxZfOyTsGE9C+Vm RYixz0zBO7ywxJnwLdCmOJobutqMuCcPc51I/rcVxy1QLVEkFbJyHaDVl9HSVgL7M84JCRKjj5 JLyOCOWvlFKVYWcDM36+3gsb X-IronPort-AV: E=Sophos;i="5.87,236,1631606400"; d="scan'208";a="68329811" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 15 Nov 2021 03:18:38 -0800 IronPort-SDR: 5bl5jP/6RfMVFqefAEux8ty+SJrdD8dX1iYxA115K6s2IEqMwK2/2SWRUnk6DjhNktD/DCSs5M iLjs6qEbHL4zsAN6H4rgtzDoJCKY6TR2fA9C4LG0QJNdvH4BRjbPn2aDKZnKdW5/QEogHQ/Hoq XoHAE97IurlvuYcvmmgIv7YX2T3MqwOQc2YGzuf7BcA2EJ4ATcAWXuep7RuCBHhK6ChkZyE7G9 hvua89MVVc2bMZffvCzGJb2KRvOFAQu2k8i/eimwuz7Pkb1ysgXox40+aDcLU/3asfpOnwQ+gw YUQ= From: Julian Brown To: Subject: [PATCH 1/4] Add debug_omp_expr Date: Mon, 15 Nov 2021 03:18:23 -0800 Message-ID: <611b69f78a05e9a4498cfb0decce9482d3088840.1636974589.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: , Cc: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The C and C++ front-ends use a TREE_LIST as a 3-tuple representing an OpenMP array section, which tends to crash debug_generic_expr if one wants to print such an expression in the debugger. This little helper function works around that. We might want to adjust the representation of array sections to use the soon-to-be-introduced OMP_ARRAY_SECTION tree code throughout instead, at which point this patch will no longer be necessary. OK? Thanks, Julian 2021-11-15 Julian Brown gcc/ * tree-pretty-print.c (print_omp_expr, debug_omp_expr): New functions. * tree-pretty-print.h (debug_omp_expr): Add prototype. --- gcc/tree-pretty-print.c | 31 +++++++++++++++++++++++++++++++ gcc/tree-pretty-print.h | 1 + 2 files changed, 32 insertions(+) diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 9d631817c59..b213bb9cec5 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -103,6 +103,37 @@ debug_generic_stmt (tree t) fprintf (stderr, "\n"); } +static void +print_omp_expr (tree t) +{ + if (TREE_CODE (t) == TREE_LIST) + { + tree low = TREE_PURPOSE (t); + tree len = TREE_VALUE (t); + tree base = TREE_CHAIN (t); + if (TREE_CODE (base) == TREE_LIST) + print_omp_expr (base); + else + print_generic_expr (stderr, base, TDF_VOPS|TDF_MEMSYMS); + fprintf (stderr, "["); + if (low) + print_generic_expr (stderr, low, TDF_VOPS|TDF_MEMSYMS); + fprintf (stderr, ":"); + if (len) + print_generic_expr (stderr, len, TDF_VOPS|TDF_MEMSYMS); + fprintf (stderr, "]"); + } + else + print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS); +} + +DEBUG_FUNCTION void +debug_omp_expr (tree t) +{ + print_omp_expr (t); + fprintf (stderr, "\n"); +} + /* Debugging function to print out a chain of trees . */ DEBUG_FUNCTION void diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h index dacd256302b..bc910f9a1b1 100644 --- a/gcc/tree-pretty-print.h +++ b/gcc/tree-pretty-print.h @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see extern void debug_generic_expr (tree); extern void debug_generic_stmt (tree); +extern void debug_omp_expr (tree); extern void debug_tree_chain (tree); extern void print_generic_decl (FILE *, tree, dump_flags_t); extern void print_generic_stmt (FILE *, tree, dump_flags_t = TDF_NONE);