public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/99951] New: Dead return value after modify_call() is not released
@ 2021-04-07  7:00 fxue at os dot amperecomputing.com
  2021-04-07  7:39 ` [Bug ipa/99951] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fxue at os dot amperecomputing.com @ 2021-04-07  7:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

            Bug ID: 99951
           Summary: Dead return value after modify_call() is not released
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxue at os dot amperecomputing.com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

By ipa_param_adjustments::modify_call(), a call statement with return value
might be replaced to a new void-return call. But the original return value SSA
is not released, which would give us garbage SSA when traversing
FOR_EACH_SSA_NAME.

In the following code, all uses of stmt's lhs are redirected to a new one, and
it becomes unused, but is never released from SSA name table.

  if (tree lhs = gimple_call_lhs (stmt))
    {
      if (!m_skip_return)
        gimple_call_set_lhs (new_stmt, lhs);
      else if (TREE_CODE (lhs) == SSA_NAME)
        {
          /* LHS should now by a default-def SSA.  Unfortunately default-def
             SSA_NAMEs need a backing variable (or at least some code examining
             SSAs assumes it is non-NULL).  So we either have to re-use the
             decl we have at hand or introdice a new one.  */
          tree repl = create_tmp_var (TREE_TYPE (lhs), "removed_return");
          repl = get_or_create_ssa_default_def (cfun, repl);
          SSA_NAME_IS_DEFAULT_DEF (repl) = true;
          imm_use_iterator ui;
          use_operand_p use_p;
          gimple *using_stmt;
          FOR_EACH_IMM_USE_STMT (using_stmt, ui, lhs)
            {
              FOR_EACH_IMM_USE_ON_STMT (use_p, ui)
                {
                  SET_USE (use_p, repl);
                }
              update_stmt (using_stmt);
            }
        }
    }

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

* [Bug ipa/99951] Dead return value after modify_call() is not released
  2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
@ 2021-04-07  7:39 ` rguenth at gcc dot gnu.org
  2021-04-08  1:38 ` fxue at os dot amperecomputing.com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-07  7:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-04-07
     Ever confirmed|0                           |1
                 CC|                            |jamborm at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
            Version|tree-ssa                    |11.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Martin, can you fix?

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

* [Bug ipa/99951] Dead return value after modify_call() is not released
  2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
  2021-04-07  7:39 ` [Bug ipa/99951] " rguenth at gcc dot gnu.org
@ 2021-04-08  1:38 ` fxue at os dot amperecomputing.com
  2021-04-08  7:21 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxue at os dot amperecomputing.com @ 2021-04-08  1:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

--- Comment #2 from Feng Xue <fxue at os dot amperecomputing.com> ---
Can we report error in verify_ssa() when a non-default SSA's defining statement
has NULL bb, which is always a case that the statement is removed somewhere?

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

* [Bug ipa/99951] Dead return value after modify_call() is not released
  2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
  2021-04-07  7:39 ` [Bug ipa/99951] " rguenth at gcc dot gnu.org
  2021-04-08  1:38 ` fxue at os dot amperecomputing.com
@ 2021-04-08  7:21 ` rguenth at gcc dot gnu.org
  2021-04-08  9:25 ` jamborm at gcc dot gnu.org
  2021-04-27 11:46 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-08  7:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Feng Xue from comment #2)
> Can we report error in verify_ssa() when a non-default SSA's defining
> statement has NULL bb, which is always a case that the statement is removed
> somewhere?

We can, but that triggers way too often ... but be my guest chasing all of them
down.  [we could also simply release them, eh]

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

* [Bug ipa/99951] Dead return value after modify_call() is not released
  2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
                   ` (2 preceding siblings ...)
  2021-04-08  7:21 ` rguenth at gcc dot gnu.org
@ 2021-04-08  9:25 ` jamborm at gcc dot gnu.org
  2021-04-27 11:46 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jamborm at gcc dot gnu.org @ 2021-04-08  9:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jamborm at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I posted a patch calling release_ssa on the SSA_NAME to the mailing list:
https://gcc.gnu.org/pipermail/gcc-patches/2021-April/567759.html

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

* [Bug ipa/99951] Dead return value after modify_call() is not released
  2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
                   ` (3 preceding siblings ...)
  2021-04-08  9:25 ` jamborm at gcc dot gnu.org
@ 2021-04-27 11:46 ` cvs-commit at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-27 11:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99951

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:eea82246290010addf7f6be71a71b51079b3cb5d

commit r12-149-geea82246290010addf7f6be71a71b51079b3cb5d
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Apr 27 13:46:10 2021 +0200

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

    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.

    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.

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

end of thread, other threads:[~2021-04-27 11:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07  7:00 [Bug ipa/99951] New: Dead return value after modify_call() is not released fxue at os dot amperecomputing.com
2021-04-07  7:39 ` [Bug ipa/99951] " rguenth at gcc dot gnu.org
2021-04-08  1:38 ` fxue at os dot amperecomputing.com
2021-04-08  7:21 ` rguenth at gcc dot gnu.org
2021-04-08  9:25 ` jamborm at gcc dot gnu.org
2021-04-27 11:46 ` cvs-commit at gcc dot gnu.org

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