public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/3] rtl-ssa: Provide easier access to debug uses [PR113089]
@ 2024-01-19  9:04 Alex Coplan
  2024-01-22 16:12 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Coplan @ 2024-01-19  9:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Sandiford, Kyrylo Tkachov, Richard Earnshaw

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

This patch adds some accessors to set_info and use_info to make it
easier to get at and iterate through uses in debug insns.

It is used by the aarch64 load/store pair fusion pass in a subsequent
patch to fix PR113089, i.e. to update debug uses in the pass.

Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without
the load/store pair pass enabled), OK for trunk?

gcc/ChangeLog:

	PR target/113089
	* rtl-ssa/accesses.h (use_info::next_debug_insn_use): New.
	(debug_insn_use_iterator): New.
	(set_info::first_debug_insn_use): New.
	(set_info::debug_insn_uses): New.
	* rtl-ssa/member-fns.inl (use_info::next_debug_insn_use): New.
	(set_info::first_debug_insn_use): New.
	(set_info::debug_insn_uses): New.
---
 gcc/rtl-ssa/accesses.h     | 13 +++++++++++++
 gcc/rtl-ssa/member-fns.inl | 29 +++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)


[-- Attachment #2: 0001-rtl-ssa-Provide-easier-access-to-debug-uses-PR113089.patch --]
[-- Type: text/x-patch, Size: 3290 bytes --]

diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h
index 6a3ecd32848..c57b8a8b7b5 100644
--- a/gcc/rtl-ssa/accesses.h
+++ b/gcc/rtl-ssa/accesses.h
@@ -357,6 +357,10 @@ public:
   //    next_use () && next_use ()->is_in_any_insn () ? next_use () : nullptr
   use_info *next_any_insn_use () const;
 
+  // Return the next use by a debug instruction, or null if none.
+  // This is only valid if if is_in_debug_insn ().
+  use_info *next_debug_insn_use () const;
+
   // Return the previous use by a phi node in the list, or null if none.
   //
   // This is only valid if is_in_phi ().  It is equivalent to:
@@ -458,6 +462,8 @@ using reverse_use_iterator = list_iterator<use_info, &use_info::prev_use>;
 // of use in the same definition.
 using nondebug_insn_use_iterator
   = list_iterator<use_info, &use_info::next_nondebug_insn_use>;
+using debug_insn_use_iterator
+  = list_iterator<use_info, &use_info::next_debug_insn_use>;
 using any_insn_use_iterator
   = list_iterator<use_info, &use_info::next_any_insn_use>;
 using phi_use_iterator = list_iterator<use_info, &use_info::prev_phi_use>;
@@ -680,6 +686,10 @@ public:
   use_info *first_nondebug_insn_use () const;
   use_info *last_nondebug_insn_use () const;
 
+  // Return the first use of the set by debug instructions, or null if
+  // there is no such use.
+  use_info *first_debug_insn_use () const;
+
   // Return the first use of the set by any kind of instruction, or null
   // if there are no such uses.  The uses are in the order described above.
   use_info *first_any_insn_use () const;
@@ -731,6 +741,9 @@ public:
   // List the uses of the set by nondebug instructions, in reverse postorder.
   iterator_range<nondebug_insn_use_iterator> nondebug_insn_uses () const;
 
+  // List the uses of the set by debug instructions, in reverse postorder.
+  iterator_range<debug_insn_use_iterator> debug_insn_uses () const;
+
   // Return nondebug_insn_uses () in reverse order.
   iterator_range<reverse_use_iterator> reverse_nondebug_insn_uses () const;
 
diff --git a/gcc/rtl-ssa/member-fns.inl b/gcc/rtl-ssa/member-fns.inl
index 8e1c17ced95..e4825ad2a18 100644
--- a/gcc/rtl-ssa/member-fns.inl
+++ b/gcc/rtl-ssa/member-fns.inl
@@ -119,6 +119,15 @@ use_info::next_any_insn_use () const
   return nullptr;
 }
 
+inline use_info *
+use_info::next_debug_insn_use () const
+{
+  if (auto use = next_use ())
+    if (use->is_in_debug_insn ())
+      return use;
+  return nullptr;
+}
+
 inline use_info *
 use_info::prev_phi_use () const
 {
@@ -212,6 +221,20 @@ set_info::last_nondebug_insn_use () const
   return nullptr;
 }
 
+inline use_info *
+set_info::first_debug_insn_use () const
+{
+  use_info *use;
+  if (has_nondebug_insn_uses ())
+    use = last_nondebug_insn_use ()->next_use ();
+  else
+    use = first_use ();
+
+  if (use && use->is_in_debug_insn ())
+    return use;
+  return nullptr;
+}
+
 inline use_info *
 set_info::first_any_insn_use () const
 {
@@ -310,6 +333,12 @@ set_info::nondebug_insn_uses () const
   return { first_nondebug_insn_use (), nullptr };
 }
 
+inline iterator_range<debug_insn_use_iterator>
+set_info::debug_insn_uses () const
+{
+  return { first_debug_insn_use (), nullptr };
+}
+
 inline iterator_range<reverse_use_iterator>
 set_info::reverse_nondebug_insn_uses () const
 {

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

* Re: [PATCH 1/3] rtl-ssa: Provide easier access to debug uses [PR113089]
  2024-01-19  9:04 [PATCH 1/3] rtl-ssa: Provide easier access to debug uses [PR113089] Alex Coplan
@ 2024-01-22 16:12 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2024-01-22 16:12 UTC (permalink / raw)
  To: Alex Coplan; +Cc: gcc-patches, Kyrylo Tkachov, Richard Earnshaw

Alex Coplan <alex.coplan@arm.com> writes:
> This patch adds some accessors to set_info and use_info to make it
> easier to get at and iterate through uses in debug insns.
>
> It is used by the aarch64 load/store pair fusion pass in a subsequent
> patch to fix PR113089, i.e. to update debug uses in the pass.
>
> Bootstrapped/regtested as a series on aarch64-linux-gnu (with/without
> the load/store pair pass enabled), OK for trunk?
>
> gcc/ChangeLog:
>
> 	PR target/113089
> 	* rtl-ssa/accesses.h (use_info::next_debug_insn_use): New.
> 	(debug_insn_use_iterator): New.
> 	(set_info::first_debug_insn_use): New.
> 	(set_info::debug_insn_uses): New.
> 	* rtl-ssa/member-fns.inl (use_info::next_debug_insn_use): New.
> 	(set_info::first_debug_insn_use): New.
> 	(set_info::debug_insn_uses): New.

OK, thanks.

Richard

> ---
>  gcc/rtl-ssa/accesses.h     | 13 +++++++++++++
>  gcc/rtl-ssa/member-fns.inl | 29 +++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
>
> diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h
> index 6a3ecd32848..c57b8a8b7b5 100644
> --- a/gcc/rtl-ssa/accesses.h
> +++ b/gcc/rtl-ssa/accesses.h
> @@ -357,6 +357,10 @@ public:
>    //    next_use () && next_use ()->is_in_any_insn () ? next_use () : nullptr
>    use_info *next_any_insn_use () const;
>  
> +  // Return the next use by a debug instruction, or null if none.
> +  // This is only valid if if is_in_debug_insn ().
> +  use_info *next_debug_insn_use () const;
> +
>    // Return the previous use by a phi node in the list, or null if none.
>    //
>    // This is only valid if is_in_phi ().  It is equivalent to:
> @@ -458,6 +462,8 @@ using reverse_use_iterator = list_iterator<use_info, &use_info::prev_use>;
>  // of use in the same definition.
>  using nondebug_insn_use_iterator
>    = list_iterator<use_info, &use_info::next_nondebug_insn_use>;
> +using debug_insn_use_iterator
> +  = list_iterator<use_info, &use_info::next_debug_insn_use>;
>  using any_insn_use_iterator
>    = list_iterator<use_info, &use_info::next_any_insn_use>;
>  using phi_use_iterator = list_iterator<use_info, &use_info::prev_phi_use>;
> @@ -680,6 +686,10 @@ public:
>    use_info *first_nondebug_insn_use () const;
>    use_info *last_nondebug_insn_use () const;
>  
> +  // Return the first use of the set by debug instructions, or null if
> +  // there is no such use.
> +  use_info *first_debug_insn_use () const;
> +
>    // Return the first use of the set by any kind of instruction, or null
>    // if there are no such uses.  The uses are in the order described above.
>    use_info *first_any_insn_use () const;
> @@ -731,6 +741,9 @@ public:
>    // List the uses of the set by nondebug instructions, in reverse postorder.
>    iterator_range<nondebug_insn_use_iterator> nondebug_insn_uses () const;
>  
> +  // List the uses of the set by debug instructions, in reverse postorder.
> +  iterator_range<debug_insn_use_iterator> debug_insn_uses () const;
> +
>    // Return nondebug_insn_uses () in reverse order.
>    iterator_range<reverse_use_iterator> reverse_nondebug_insn_uses () const;
>  
> diff --git a/gcc/rtl-ssa/member-fns.inl b/gcc/rtl-ssa/member-fns.inl
> index 8e1c17ced95..e4825ad2a18 100644
> --- a/gcc/rtl-ssa/member-fns.inl
> +++ b/gcc/rtl-ssa/member-fns.inl
> @@ -119,6 +119,15 @@ use_info::next_any_insn_use () const
>    return nullptr;
>  }
>  
> +inline use_info *
> +use_info::next_debug_insn_use () const
> +{
> +  if (auto use = next_use ())
> +    if (use->is_in_debug_insn ())
> +      return use;
> +  return nullptr;
> +}
> +
>  inline use_info *
>  use_info::prev_phi_use () const
>  {
> @@ -212,6 +221,20 @@ set_info::last_nondebug_insn_use () const
>    return nullptr;
>  }
>  
> +inline use_info *
> +set_info::first_debug_insn_use () const
> +{
> +  use_info *use;
> +  if (has_nondebug_insn_uses ())
> +    use = last_nondebug_insn_use ()->next_use ();
> +  else
> +    use = first_use ();
> +
> +  if (use && use->is_in_debug_insn ())
> +    return use;
> +  return nullptr;
> +}
> +
>  inline use_info *
>  set_info::first_any_insn_use () const
>  {
> @@ -310,6 +333,12 @@ set_info::nondebug_insn_uses () const
>    return { first_nondebug_insn_use (), nullptr };
>  }
>  
> +inline iterator_range<debug_insn_use_iterator>
> +set_info::debug_insn_uses () const
> +{
> +  return { first_debug_insn_use (), nullptr };
> +}
> +
>  inline iterator_range<reverse_use_iterator>
>  set_info::reverse_nondebug_insn_uses () const
>  {

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

end of thread, other threads:[~2024-01-22 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19  9:04 [PATCH 1/3] rtl-ssa: Provide easier access to debug uses [PR113089] Alex Coplan
2024-01-22 16:12 ` Richard Sandiford

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