From patchwork Thu Nov 25 14:10:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 48151 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 30666385E00E for ; Thu, 25 Nov 2021 14:17:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 22A18385843A for ; Thu, 25 Nov 2021 14:10:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 22A18385843A 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: TPVUKMKvEJ5Felj2pS5vIDwn2DBSVc08hQWa/hPqrU2yQ0nsbEU8dlgLzBGR3HtVfHJxGoWrUZ nBanDzeDApGxyH54F3z5bhrvcNA/Q3A8vFyUNTbrjbnzYQGHPyOGEnky2rBW1VbGwCu1p/Dsdf jyA8y+Avh6q1u3sV9M9MYCoHmJGl3MIPGl/PBDaRlfJ3D/LQNNWZlQRPSR8cQlHmoplC7tXlg3 lJo4Tl1GjRsmQBPK+sasiaWy7rg8tim70bCrhUfN5iQxXRQfbY3w8CNNJi0YlXW7q+CZRLBzS1 da9rIM+S9i6oVVaiVV5EuXaz X-IronPort-AV: E=Sophos;i="5.87,263,1631606400"; d="scan'208";a="68920870" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 25 Nov 2021 06:10:30 -0800 IronPort-SDR: gwMP/OKGfVWVrh5eisxntX5BTQJAO2Y5YlQEhuiyas87B2WX2wUWSVaJ6R3+VooBKURCGsZqaB 7FJFb8/Vson113iOagsmC6+eUYKHVLqFBqYlwfMTSwEeZlumKQ5Ic+Pyo4KfrPURBcc3JJQwMq 2U19RAOzfIIQqMonn4rBhEO5FkEY2Lylk59CsCP3Xu4zt8Byjk/AshJ3uBZV1l6niQI2qC+FcX DX/KozRhj4VLD9IXqsUvVYiqFk4Syu7GL5ULzvKL9kpWv8DEBDe43RfrE89ujqobeb3CRUAIDk rgk= From: Julian Brown To: Subject: [PATCH 13/16] Add debug_omp_expr Date: Thu, 25 Nov 2021 06:10:12 -0800 Message-ID: <20211125141013.113782-4-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211125141013.113782-1-julian@codesourcery.com> References: <20211125141013.113782-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) 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 , Thomas Schwinge Errors-To: gcc-patches-bounces+patchwork=sourceware.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 a81ba401ef9..13b64fd52e1 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);