public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
	Thomas Schwinge <thomas@codesourcery.com>
Subject: [PATCH 13/16] Add debug_omp_expr
Date: Thu, 25 Nov 2021 06:10:12 -0800	[thread overview]
Message-ID: <20211125141013.113782-4-julian@codesourcery.com> (raw)
In-Reply-To: <20211125141013.113782-1-julian@codesourcery.com>

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  <julian@codesourcery.com>

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);
-- 
2.29.2


  parent reply	other threads:[~2021-11-25 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 14:10 [PATCH 10/16] OpenMP: Fix non-zero attach/detach bias for struct dereferences Julian Brown
2021-11-25 14:10 ` [PATCH 11/16] OpenMP: Handle reference-typed struct members Julian Brown
2021-11-25 14:10 ` [PATCH 12/16] OpenACC: Make deep-copy-arrayofstruct.c a libgomp/runtime test Julian Brown
2021-11-25 14:10 ` Julian Brown [this message]
2021-11-25 14:10 ` [PATCH 14/16] OpenMP: Add inspector class to unify mapped address analysis Julian Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211125141013.113782-4-julian@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=thomas@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).