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

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