public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Remove TDF_THREADING flag in favor of param.
@ 2021-11-09 11:14 Aldy Hernandez
  2021-11-09 11:14 ` [COMMITTED] Cleanup path solver dumps Aldy Hernandez
  2021-11-09 14:10 ` [COMMITTED] Remove TDF_THREADING flag in favor of param Martin Liška
  0 siblings, 2 replies; 9+ messages in thread
From: Aldy Hernandez @ 2021-11-09 11:14 UTC (permalink / raw)
  To: GCC patches

I am returning a TDF_* flag to the queue of available entries as I am
unconvinced that we need to burn an entire flag for internal debugging
constructs, especially since we seem to be running out of them.

I've added a --param=threader-debug entry similar to the one we use for
ranger debugging.  Currently this only affects the backward threader,
but since the DOM threader is an outlier and on the chopping block, I
avoided using the "backward" name.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* dumpfile.c (dump_options): Remove TDF_THREADING entry.
	* dumpfile.h (enum dump_flag): Remove TDF_THREADING and adjust
	remaining entries.
	* flag-types.h (enum threader_debug): New.
	* gimple-range-path.cc (DEBUG_SOLVER): Use param_threader_debug.
	* params.opt: Add entry for --param=threader-debug=.
---
 gcc/dumpfile.c           |  1 -
 gcc/dumpfile.h           | 23 ++++++++++-------------
 gcc/flag-types.h         |  7 +++++++
 gcc/gimple-range-path.cc |  2 +-
 gcc/params.opt           | 13 +++++++++++++
 5 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index e6ead5debe5..8169daf7f59 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -145,7 +145,6 @@ static const kv_pair<dump_flags_t> dump_options[] =
   {"missed", MSG_MISSED_OPTIMIZATION},
   {"note", MSG_NOTE},
   {"optall", MSG_ALL_KINDS},
-  {"threading", TDF_THREADING},
   {"all", dump_flags_t (TDF_ALL_VALUES
 			& ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_GRAPH
 			    | TDF_STMTADDR | TDF_RHS_ONLY | TDF_NOUID
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index 76226753845..2487ae243c6 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -146,20 +146,17 @@ enum dump_flag : uint32_t
   /* Dump folding details.  */
   TDF_FOLDING = (1 << 21),
 
-  /* Dumping for range path solver.  */
-  TDF_THREADING = (1 << 22),
-
   /* MSG_* flags for expressing the kinds of message to
      be emitted by -fopt-info.  */
 
   /* -fopt-info optimized sources.  */
-  MSG_OPTIMIZED_LOCATIONS = (1 << 23),
+  MSG_OPTIMIZED_LOCATIONS = (1 << 22),
 
   /* Missed opportunities.  */
-  MSG_MISSED_OPTIMIZATION = (1 << 24),
+  MSG_MISSED_OPTIMIZATION = (1 << 23),
 
   /* General optimization info.  */
-  MSG_NOTE = (1 << 25),
+  MSG_NOTE = (1 << 24),
 
   /* Mask for selecting MSG_-kind flags.  */
   MSG_ALL_KINDS = (MSG_OPTIMIZED_LOCATIONS
@@ -178,16 +175,16 @@ enum dump_flag : uint32_t
      sub-option of -fopt-info to show the internal messages.  */
 
   /* Implicitly supplied for messages at the top-level dump scope.  */
-  MSG_PRIORITY_USER_FACING = (1 << 26),
+  MSG_PRIORITY_USER_FACING = (1 << 25),
 
   /* Implicitly supplied for messages within nested dump scopes.  */
-  MSG_PRIORITY_INTERNALS = (1 << 27),
+  MSG_PRIORITY_INTERNALS = (1 << 26),
 
   /* Supplied when an opt_problem generated in a nested scope is re-emitted
      at the top-level.   We want to default to showing these in -fopt-info
      output, but to *not* show them in dump files, as the message would be
      shown twice, messing up "scan-tree-dump-times" in DejaGnu tests.  */
-  MSG_PRIORITY_REEMITTED = (1 << 28),
+  MSG_PRIORITY_REEMITTED = (1 << 27),
 
   /* Mask for selecting MSG_PRIORITY_* flags.  */
   MSG_ALL_PRIORITIES = (MSG_PRIORITY_USER_FACING
@@ -195,16 +192,16 @@ enum dump_flag : uint32_t
 			| MSG_PRIORITY_REEMITTED),
 
   /* All -fdump- flags.  */
-  TDF_ALL_VALUES = (1 << 29) - 1,
+  TDF_ALL_VALUES = (1 << 28) - 1,
 
   /* Dumping for -fcompare-debug.  */
-  TDF_COMPARE_DEBUG = (1 << 29),
+  TDF_COMPARE_DEBUG = (1 << 28),
 
   /* Dump a GIMPLE value which means wrapping certain things with _Literal.  */
-  TDF_GIMPLE_VAL = (1 << 30),
+  TDF_GIMPLE_VAL = (1 << 29),
 
   /* For error.  */
-  TDF_ERROR = ((uint32_t)1 << 31),
+  TDF_ERROR = ((uint32_t)1 << 30),
 };
 
 /* Dump flags type.  */
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 459e3e07016..cfd2a5f6f50 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -462,6 +462,13 @@ enum ranger_debug
 		      | RANGER_DEBUG_TRACE)
 };
 
+/* Jump threader verbose dumps.  */
+enum threader_debug
+{
+  THREADER_DEBUG_NONE = 0,
+  THREADER_DEBUG_ALL = 1
+};
+
 /* EVRP mode.  */
 enum evrp_mode
 {
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 9d3fe89185e..52de10369f3 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-iterator.h"
 
 // Internal construct to help facilitate debugging of solver.
-#define DEBUG_SOLVER (dump_file && dump_flags & TDF_THREADING)
+#define DEBUG_SOLVER (dump_file && (param_threader_debug == THREADER_DEBUG_ALL))
 
 path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
   : m_ranger (ranger)
diff --git a/gcc/params.opt b/gcc/params.opt
index 4b409d55a2d..e725c99e5e4 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1047,6 +1047,19 @@ Maximum number of escape points tracked by modref per SSA-name.
 Common Joined UInteger Var(param_modref_max_adjustments) Init(8) IntegerRange(0, 254) Param Optimization
 Maximum number of times a given range is adjusted during the dataflow.
 
+-param=threader-debug=
+Common Joined Var(param_threader_debug) Enum(threader_debug) Init(THREADER_DEBUG_NONE) Param Optimization
+--param=threader-debug=[none|all] Enables verbose dumping of the threader solver.
+
+Enum
+Name(threader_debug) Type(enum threader_debug) UnknownError(unknown threader debug mode %qs)
+
+EnumValue
+Enum(threader_debug) String(none) Value(THREADER_DEBUG_NONE)
+
+EnumValue
+Enum(threader_debug) String(all) Value(THREADER_DEBUG_ALL)
+
 -param=tm-max-aggregate-size=
 Common Joined UInteger Var(param_tm_max_aggregate_size) Init(9) Param Optimization
 Size in bytes after which thread-local aggregates should be instrumented with the logging functions instead of save/restore pairs.
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [COMMITTED] Cleanup path solver dumps.
  2021-11-09 11:14 [COMMITTED] Remove TDF_THREADING flag in favor of param Aldy Hernandez
@ 2021-11-09 11:14 ` Aldy Hernandez
  2021-11-09 14:10 ` [COMMITTED] Remove TDF_THREADING flag in favor of param Martin Liška
  1 sibling, 0 replies; 9+ messages in thread
From: Aldy Hernandez @ 2021-11-09 11:14 UTC (permalink / raw)
  To: GCC patches

This patch makes the path solver dumps a bit more consistent.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-path.cc (path_range_query::dump): Clean up.
	(path_range_query::compute_ranges): Same.
	* value-relation.cc (path_oracle::dump): Same.
---
 gcc/gimple-range-path.cc | 11 ++++-------
 gcc/value-relation.cc    |  6 +++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 52de10369f3..99ac947581b 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -98,7 +98,6 @@ path_range_query::dump (FILE *dump_file)
   unsigned i;
   bitmap_iterator bi;
 
-  fprintf (dump_file, "\nPath is (length=%d):\n", m_path->length ());
   dump_ranger (dump_file, *m_path);
 
   fprintf (dump_file, "Imports:\n");
@@ -505,7 +504,7 @@ path_range_query::compute_ranges (const vec<basic_block> &path,
 				  const bitmap_head *imports)
 {
   if (DEBUG_SOLVER)
-    fprintf (dump_file, "\n*********** path_range_query ******************\n");
+    fprintf (dump_file, "\n==============================================\n");
 
   set_path (path);
   bitmap_copy (m_imports, imports);
@@ -519,13 +518,13 @@ path_range_query::compute_ranges (const vec<basic_block> &path,
 
   if (DEBUG_SOLVER)
     {
-      fprintf (dump_file, "\npath_range_query: compute_ranges for path: ");
+      fprintf (dump_file, "path_range_query: compute_ranges for path: ");
       for (unsigned i = path.length (); i > 0; --i)
 	{
 	  basic_block bb = path[i - 1];
-	  fprintf (dump_file, "BB %d", bb->index);
+	  fprintf (dump_file, "%d", bb->index);
 	  if (i > 1)
-	    fprintf (dump_file, ", ");
+	    fprintf (dump_file, "->");
 	}
       fprintf (dump_file, "\n");
     }
@@ -557,9 +556,7 @@ path_range_query::compute_ranges (const vec<basic_block> &path,
 
   if (DEBUG_SOLVER)
     {
-      fprintf (dump_file, "\npath_oracle:\n");
       get_path_oracle ()->dump (dump_file);
-      fprintf (dump_file, "\n");
       dump (dump_file);
     }
 }
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index a0105481466..9c3ecd94b13 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -1448,10 +1448,14 @@ void
 path_oracle::dump (FILE *f) const
 {
   equiv_chain *ptr = m_equiv.m_next;
+  relation_chain *ptr2 = m_relations.m_head;
+
+  if (ptr || ptr2)
+    fprintf (f, "\npath_oracle:\n");
+
   for (; ptr; ptr = ptr->m_next)
     ptr->dump (f);
 
-  relation_chain *ptr2 = m_relations.m_head;
   for (; ptr2; ptr2 = ptr2->m_next)
     {
       fprintf (f, "Relational : ");
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 11:14 [COMMITTED] Remove TDF_THREADING flag in favor of param Aldy Hernandez
  2021-11-09 11:14 ` [COMMITTED] Cleanup path solver dumps Aldy Hernandez
@ 2021-11-09 14:10 ` Martin Liška
  2021-11-09 14:22   ` Aldy Hernandez
  1 sibling, 1 reply; 9+ messages in thread
From: Martin Liška @ 2021-11-09 14:10 UTC (permalink / raw)
  To: Aldy Hernandez, GCC patches

> +-param=threader-debug=

Please document the param in gcc/doc/invoke.texi.

Missing:
@item threader-debug
threader-debug=[none|all] Enables verbose dumping of the threader solver.

Cheers,
Martin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 14:10 ` [COMMITTED] Remove TDF_THREADING flag in favor of param Martin Liška
@ 2021-11-09 14:22   ` Aldy Hernandez
  2021-11-09 14:28     ` Martin Liška
  0 siblings, 1 reply; 9+ messages in thread
From: Aldy Hernandez @ 2021-11-09 14:22 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC patches

On Tue, Nov 9, 2021 at 3:10 PM Martin Liška <mliska@suse.cz> wrote:
>
> > +-param=threader-debug=
>
> Please document the param in gcc/doc/invoke.texi.

I purposely didn't document it.  This is an internal debugging
construct.  What's our policy on this?

I'm happy to do this; I just didn't want the CI bots trying weird
combinations and reporting PRs on the size of debugging dumps, etc.
;-)

Aldy


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 14:22   ` Aldy Hernandez
@ 2021-11-09 14:28     ` Martin Liška
  2021-11-09 14:36       ` Aldy Hernandez
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Liška @ 2021-11-09 14:28 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: GCC patches

On 11/9/21 15:22, Aldy Hernandez wrote:
> On Tue, Nov 9, 2021 at 3:10 PM Martin Liška <mliska@suse.cz> wrote:
>>
>>> +-param=threader-debug=
>>
>> Please document the param in gcc/doc/invoke.texi.
> 
> I purposely didn't document it.  This is an internal debugging
> construct.  What's our policy on this?

Well, quite some params are actually intended for GCC developers only.

> 
> I'm happy to do this; I just didn't want the CI bots trying weird
> combinations and reporting PRs on the size of debugging dumps, etc.

We have all the params documented in the texi file.
I would document also this one.

Cheers,
Martin

> ;-)
> 
> Aldy
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 14:28     ` Martin Liška
@ 2021-11-09 14:36       ` Aldy Hernandez
  2021-11-09 14:39         ` Martin Liška
  0 siblings, 1 reply; 9+ messages in thread
From: Aldy Hernandez @ 2021-11-09 14:36 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC patches

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

On Tue, Nov 9, 2021 at 3:28 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 11/9/21 15:22, Aldy Hernandez wrote:
> > On Tue, Nov 9, 2021 at 3:10 PM Martin Liška <mliska@suse.cz> wrote:
> >>
> >>> +-param=threader-debug=
> >>
> >> Please document the param in gcc/doc/invoke.texi.
> >
> > I purposely didn't document it.  This is an internal debugging
> > construct.  What's our policy on this?
>
> Well, quite some params are actually intended for GCC developers only.

OK.

I don't see any ordering in these items, so I've placed it next to
another of the backward threader knobs.

How does this look?

Aldy

[-- Attachment #2: 0004-Document-param-threader-debug.patch --]
[-- Type: text/x-patch, Size: 850 bytes --]

From a9c97e1f82aac48be70e9b3bf9343874061a58ac Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Tue, 9 Nov 2021 15:33:12 +0100
Subject: [PATCH] Document --param=threader-debug.

gcc/ChangeLog:

	* doc/invoke.texi (Invoking GCC): Document --param=threader-debug.
---
 gcc/doc/invoke.texi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 95732c3fb25..2ea23d07c4c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -14518,6 +14518,9 @@ finite state automaton jump thread path.
 @item max-fsm-thread-length
 Maximum number of basic blocks on a jump thread path.
 
+@item threader-debug
+threader-debug=[none|all] Enables verbose dumping of the threader solver.
+
 @item parloops-chunk-size
 Chunk size of omp schedule for loops parallelized by parloops.
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 14:36       ` Aldy Hernandez
@ 2021-11-09 14:39         ` Martin Liška
  2021-11-09 15:29           ` Andrew MacLeod
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Liška @ 2021-11-09 14:39 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: GCC patches

On 11/9/21 15:36, Aldy Hernandez wrote:
> I don't see any ordering in these items, so I've placed it next to
> another of the backward threader knobs.
> 
> How does this look?

That's fine, thanks.

Note that similar --param 'ranger-debug' is also documented ;P

Cheers,
Martin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 14:39         ` Martin Liška
@ 2021-11-09 15:29           ` Andrew MacLeod
  2021-11-09 15:44             ` Aldy Hernandez
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew MacLeod @ 2021-11-09 15:29 UTC (permalink / raw)
  To: Martin Liška, Aldy Hernandez; +Cc: GCC patches

On 11/9/21 9:39 AM, Martin Liška wrote:
> On 11/9/21 15:36, Aldy Hernandez wrote:
>> I don't see any ordering in these items, so I've placed it next to
>> another of the backward threader knobs.
>>
>> How does this look?
>
> That's fine, thanks.
>
> Note that similar --param 'ranger-debug' is also documented ;P
>
> Cheers,
> Martin
>
yes, I finally Iearned my lesson so that Martin didn't have to clean up 
after me every time!  Get with the program! :-)

Andrew


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [COMMITTED] Remove TDF_THREADING flag in favor of param.
  2021-11-09 15:29           ` Andrew MacLeod
@ 2021-11-09 15:44             ` Aldy Hernandez
  0 siblings, 0 replies; 9+ messages in thread
From: Aldy Hernandez @ 2021-11-09 15:44 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: Martin Liška, GCC patches

On Tue, Nov 9, 2021 at 4:29 PM Andrew MacLeod <amacleod@redhat.com> wrote:
>
> On 11/9/21 9:39 AM, Martin Liška wrote:
> > On 11/9/21 15:36, Aldy Hernandez wrote:
> >> I don't see any ordering in these items, so I've placed it next to
> >> another of the backward threader knobs.
> >>
> >> How does this look?
> >
> > That's fine, thanks.
> >
> > Note that similar --param 'ranger-debug' is also documented ;P
> >
> > Cheers,
> > Martin
> >
> yes, I finally Iearned my lesson so that Martin didn't have to clean up
> after me every time!  Get with the program! :-)

You of all people should know how incredibly lazy I am.

:-P


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-09 15:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09 11:14 [COMMITTED] Remove TDF_THREADING flag in favor of param Aldy Hernandez
2021-11-09 11:14 ` [COMMITTED] Cleanup path solver dumps Aldy Hernandez
2021-11-09 14:10 ` [COMMITTED] Remove TDF_THREADING flag in favor of param Martin Liška
2021-11-09 14:22   ` Aldy Hernandez
2021-11-09 14:28     ` Martin Liška
2021-11-09 14:36       ` Aldy Hernandez
2021-11-09 14:39         ` Martin Liška
2021-11-09 15:29           ` Andrew MacLeod
2021-11-09 15:44             ` Aldy Hernandez

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).