ipa-sra: Release dead LHS SSA_NAME when removing it (PR 99951)

Message ID ri6y2dtgmdj.fsf@suse.cz
State New
Headers show
Series
  • ipa-sra: Release dead LHS SSA_NAME when removing it (PR 99951)
Related show

Commit Message

Martin Jambor April 8, 2021, 9:24 a.m.
Hi,

When IPA-SRA removes an SSA_NAME from a LHS of a call statement
because it is not necessary, it does not release it.  This patch fixes
that.

Bootstrapped and tested on x86_64, at some point I'll LTO-bootstrap it
too.  I assume this is GCC 12 material, so OK once stage 1 opens?

Thanks,

Martin


gcc/ChangeLog:

2021-04-08  Martin Jambor  <mjambor@suse.cz>

	PR ipa/99951
	* ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
	If removing a call statement LHS SSA name, release it.
---
 gcc/ipa-param-manipulation.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.30.2

Comments

Andre Vehreschild via Gcc-patches April 8, 2021, 9:58 a.m. | #1
On Thu, Apr 8, 2021 at 11:24 AM Martin Jambor <mjambor@suse.cz> wrote:
>

> Hi,

>

> When IPA-SRA removes an SSA_NAME from a LHS of a call statement

> because it is not necessary, it does not release it.  This patch fixes

> that.

>

> Bootstrapped and tested on x86_64, at some point I'll LTO-bootstrap it

> too.  I assume this is GCC 12 material, so OK once stage 1 opens?


Yes, and OK.

Richard.

> Thanks,

>

> Martin

>

>

> gcc/ChangeLog:

>

> 2021-04-08  Martin Jambor  <mjambor@suse.cz>

>

>         PR ipa/99951

>         * ipa-param-manipulation.c (ipa_param_adjustments::modify_call):

>         If removing a call statement LHS SSA name, release it.

> ---

>  gcc/ipa-param-manipulation.c | 4 ++++

>  1 file changed, 4 insertions(+)

>

> diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c

> index 132bb24f76a..1d1e64f546a 100644

> --- a/gcc/ipa-param-manipulation.c

> +++ b/gcc/ipa-param-manipulation.c

> @@ -856,6 +856,7 @@ ipa_param_adjustments::modify_call (gcall *stmt,

>

>    gcall *new_stmt = gimple_build_call_vec (callee_decl, vargs);

>

> +  tree ssa_to_remove = NULL;

>    if (tree lhs = gimple_call_lhs (stmt))

>      {

>        if (!m_skip_return)

> @@ -880,6 +881,7 @@ ipa_param_adjustments::modify_call (gcall *stmt,

>                 }

>               update_stmt (using_stmt);

>             }

> +         ssa_to_remove = lhs;

>         }

>      }

>

> @@ -898,6 +900,8 @@ ipa_param_adjustments::modify_call (gcall *stmt,

>        fprintf (dump_file, "\n");

>      }

>    gsi_replace (&gsi, new_stmt, true);

> +  if (ssa_to_remove)

> +    release_ssa_name (ssa_to_remove);

>    if (update_references)

>      do

>        {

> --

> 2.30.2

>
Andre Vehreschild via Gcc-patches April 26, 2021, 3:40 p.m. | #2
On 4/8/2021 3:24 AM, Martin Jambor wrote:
> Hi,

>

> When IPA-SRA removes an SSA_NAME from a LHS of a call statement

> because it is not necessary, it does not release it.  This patch fixes

> that.

>

> Bootstrapped and tested on x86_64, at some point I'll LTO-bootstrap it

> too.  I assume this is GCC 12 material, so OK once stage 1 opens?

>

> Thanks,

>

> Martin

>

>

> gcc/ChangeLog:

>

> 2021-04-08  Martin Jambor  <mjambor@suse.cz>

>

> 	PR ipa/99951

> 	* ipa-param-manipulation.c (ipa_param_adjustments::modify_call):

> 	If removing a call statement LHS SSA name, release it.


OK.


Somewhere around here I've got a patch which will flag SSA_NAME leaks.  
Its never been quite ready for submission, though it has proven useful 
in tracking down such issues.


jeff

Patch

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 132bb24f76a..1d1e64f546a 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -856,6 +856,7 @@  ipa_param_adjustments::modify_call (gcall *stmt,
 
   gcall *new_stmt = gimple_build_call_vec (callee_decl, vargs);
 
+  tree ssa_to_remove = NULL;
   if (tree lhs = gimple_call_lhs (stmt))
     {
       if (!m_skip_return)
@@ -880,6 +881,7 @@  ipa_param_adjustments::modify_call (gcall *stmt,
 		}
 	      update_stmt (using_stmt);
 	    }
+	  ssa_to_remove = lhs;
 	}
     }
 
@@ -898,6 +900,8 @@  ipa_param_adjustments::modify_call (gcall *stmt,
       fprintf (dump_file, "\n");
     }
   gsi_replace (&gsi, new_stmt, true);
+  if (ssa_to_remove)
+    release_ssa_name (ssa_to_remove);
   if (update_references)
     do
       {